﻿Imports System.Data.SqlClient
Imports System.Data.Odbc

Public Class frmMain
    Dim Bitacora As New clsActividad
    Private minuto As Integer = 0
    Private segundo As Integer = 0
    Private milisegundo As Integer = 0
    Private minutoM As Integer = 0
    Private segundoM As Integer = 0
    Private milisegundoM As Integer = 0
    Dim Usuario As New clsUsuarioPrincipal

    Private Sub EmpresasToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles EmpresasToolStripMenuItem.Click
        frmEmpresas.ShowDialog()
    End Sub

    Private Sub ConfiguraciónInicialToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ConfiguraciónInicialToolStripMenuItem.Click
        If UsuarioActivo.Trim <> "ADMINISTRADOR" Then
            MsgBox("No tienes permiso para ingresar a esta opcion", MsgBoxStyle.Critical, "Aviso")
            Exit Sub
        End If

        'CreaCitraGenerales()
        'CreaTablaEmpresas()
        'CreaTablaUsuarios()
        'InsertaUsuarioPrincipal()
        'CreaTablaUsuariosConectados()
        'CreaTablaFormularios()
        'CreaTablaPermisosUsuarios()
        'CreaTablaEmpresasUsuarios()

        'HASTA AQUI ES CONFIGURACION GENERAL
        'CreaTablaActividad()
        'CreaTablaRutas()
        'CreaTablaRutasOpto()
        'CreaTablaAutobuses()
        'CreaTablaAlmacenes()
        'CreaTablaTanques()
        'CreaTablaBombas()
        'CreaTablaLiquidacion()
        'CreaTablaKardex()
        'CreaTablaDiasTrabajadosLiquidacion()
        'CreaTablaConceptos()
        'CreaTablaEmpleados()
        'CreaTablaDepartamentos()
        'CreaTablaPuestos()
        'CreaTablaTurnos()
        'CreaTablaPeriodos()
        'CreaTablaIncapacidades()
        'CreaTablaMeses()
        'CreaTablaBimestres()
        'CreaTablaCargosFonacot()
        'CreaTablaCargosInfonavit()
        'CreaTablaInfonavitFonacot()
        'CreaTablaReportes()
        'CreaTablaAccidentes()
        'CreaTablaGratificaciones()
        'CreaTablaPermisos()
        'CreaTablaVacaciones()
        'CreaTablaAdeudos()
        'CreaTablaMovimientos()
        'CreaTablaOtrosCargos()
        'CreaTablaObservaciones()
        'CreaTablaBajas()
        'CreaTablaGafetes()
        'CreaTablaFianzas()
        'CreaTablaLicencias()
        'CreaTablaAltas()
        'CreaTablaPagobus()
        'CreaTablaDiasTrabajadoPagobus()
        'CreaTablaFactores()
        'CreaTablaCapacitacion()
        'CreaTablaUniformes()
        'CreaTablaEvaluacionInternaDetalle()
        'CreaTablaEvaluacionInternaTotales()
        'CreaTablaEvaluacionDetalle()
        'CreaTablaEvaluacioTotales()
        'CreaTablaSalariosMinimos()
        'CreaTablaPrecioVueltas()
        'CreaTablaNominaGeneral()
        'CreaTablaNominaDetalle()
        'CreaTablaAbonosInfonavit()
        'CreaTablaAbonosFonacot()
        'CreaTablaSueldosAcumulados()
        'CreaTablaDiesel()
        'CreaTablaDieselTemp()
        'CreaTablaPreventivos()
        'CreaTablaMantenimientos()
        'CreaTablaOrdenDetalleServicios()
        'CreaTablOrdenDetalleProductos()
        'CreaTablaProductos()
        'CreaTablaServicios()
        'CreaTablaSubServicios()
        'CreaTablaAsignacionServicios()
        'CreaTablaAgignacionBiometria()
        'CreaTablaHorariosDiesel()
        'CreaTablaDieselSinRecorrido()
        'CreaTablaKilometrosOperativos()
        'CreaTablaDiasTrabajadosDiesel()
        'CreaTablaCuboEgresos()
        'CreaTablaCuboIngresos()
        'CreaTablaCuentasContables()
        'CreaTablaCuboContables()
        'CreaTablaCuboKilometros()
        'CreaTablaDocumentosADM()
        'CreaTablaMovimientosADM()
        'CreaTablaPorcentajesGeneralesEvaluacion()
        'CreaTablaE_Despachos()
        'CreaTablaE_Presentacion()
        'CreaTablaE_Servicios()
        'CreaTablaE_Rendimiento()
        'CreaTablaE_Diesel()
        'CreaTablaE_Ventas()
        'CreaTablaE_Productividad()
        'CreaTablaE_MatrizEvaluacion()
        'CreaTablaE_Incentivos()
        'CreaTablaE_Porcentajes()
        'CreaTablaE_Roles()
        'CreaTablaEMI_Global()
        'CreaTablaEMI_Citas()
        'CreaTablaEMI_Notas()
        'CreaTablaEMI_Anexos()
        'CreaTablaEMI_Catalogo()
        'CreaTablaEMI_Consulta()
        'CreaTablaEMI_Motivo()
        'CreaTablaEMI_Patologias()
        'CreaTablaPresupuesto()
        'CreaTablaBiometria()
        'CreaTablaEvaluacionOLDDetalle()
        'CreaTablaEvaluacionOLDTotales()
        'CreaTablaAdeudosTradicionales()
        'CreaTablaIP()
        'CreaTablaTarjetas()
        'CreaTablaPagobusDetallado()
        'CreaTablaSabanas()
        'CreaTablaSabanasBoletos()
        'CreaTablaRolesDescuentos()
        'CreaRecaudacion()
        'CreaTablaSabanasArchivo()
        'CrearBD_skeleton()
        'CreaTablaSKELETON_RegistroTR()
        'CreaTablaSKELETON_PasajerosRecorrido()
        'CreaTablaSKELETON_PasajerosSubida()
        'CreaTablaSKELETON_PasajerosBajada()
        'CreaTablaSKELETON_PasajerosBajadaAuxiliar()
        'CreaTablaSKELETON_PasajerosAbordo()
        'CreaTablaPlanOperacion()
        'CreaTablaDiasOperacion()
        'CreaTablaNominasIngreso()
        'CreaTablaPrecioVueltasBella()
        'CreaTablaCot_Documentos()
        'CreaTablaCot_Generales()
        'CreaTablaCot_Detalle()
        'CreaTablaCot_Anexos()
        'CreaTablaCot_Solicitud()
        'CreaTablaCot_SolicitudDetalle()
        'CreaReporteGeneral()
        'CreaInfoAXR()
        'CreaInfoTroncalIngreso()
        'CreaInfoTroncalMovilidad()
        'CreaInfoTroncalServiciosProgramados()
        'CreaInfoTroncalServiciosVacios()
        'CreaInfoTroncalServiciosReales()
        'CreaValidacionesPagobus()
        'CreaSabanasEnvios()
        'CreaSabanasBoletosSobrantes()
        'CreaKilometros()
        'CreaTablaOperadoresGlobal()
        'CreaOrdenDiesel()
        'CreaCorteDiesel()
        'CreaStatusCargaDiesel()
        'CreaStatusCorteDiesel()
        'CreaPedidos()
        'CreaPedidosDetalle()
        'CreaPedidosProveedor()
        'CreaPedidosConcepto()
        'CreaKmsAcumulado()
        'CreaKmsMensuales()
        'CreaKmsDetalle()


    End Sub
    Sub CreaKmsDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE KmsDetalle (" & _
"IdDetalle INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Kms DECIMAL(18,2) NOT NULL," & _
"kmsTrabajados DECIMAL(18,2) NOT NULL," & _
"KmsMuertos DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaKmsMensuales()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE KmsMensuales (" & _
"IdMensuales INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"KmsAcumulados DECIMAL(18,2) NOT NULL," & _
"kmsTrabajados DECIMAL(18,2) NOT NULL," & _
"KmsMuertos DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaKmsAcumulado()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE KmsAcumulado (" & _
"IdAcumulado INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"KmsAcumulado DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaPedidosConcepto()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE PedidosConcepto (" & _
"IdConcepto INTEGER NOT NULL," & _
"Codigo VARCHAR(200) NOT NULL," & _
"Nombre VARCHAR(500) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaPedidosProveedor()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE PedidosProveedor (" & _
"IdProveedor INTEGER NOT NULL," & _
"Codigo VARCHAR(200) NOT NULL," & _
"Nombre VARCHAR(500) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaPedidosDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE PedidosDetalle (" & _
"IdPedidoDetalle INTEGER IDENTITY NOT NULL," & _
"IdPedido INTEGER NOT NULL," & _
"Codigo VARCHAR(200) NOT NULL," & _
"Producto VARCHAR(500) NOT NULL," & _
"Existencia DECIMAL(12,2) NOT NULL," & _
"Maximo DECIMAL(12,2) NOT NULL," & _
"Minimo DECIMAL(12,2) NOT NULL," & _
"Media DECIMAL(12,2) NOT NULL," & _
"Pedir DECIMAL(12,2) NOT NULL," & _
"Observaciones VARCHAR(200) NOT NULL," & _
"Enviar INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaPedidos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Pedidos (" & _
"IdPedido INTEGER IDENTITY NOT NULL," & _
"Almacen VARCHAR(200) NOT NULL," & _
"Familia VARCHAR(200) NOT NULL," & _
"FechaCalculo DATETIME NOT NULL," & _
"Usuario VARCHAR(50) NOT NULL," & _
"AdminPAQ INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaStatusCorteDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE StatusCorteDiesel (" & _
"IdStatus INTEGER IDENTITY NOT NULL," & _
"IdTanque INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaStatusCargaDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE StatusCargaDiesel (" & _
"IdStatus INTEGER IDENTITY NOT NULL," & _
"IdTanque INTEGER NOT NULL," & _
"IdAutobus DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaCorteDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE CorteDiesel (" & _
"IdCorte INTEGER IDENTITY NOT NULL," & _
"IdDiesel INTEGER NOT NULL," & _
"IdTanque INTEGER NOT NULL," & _
"Cuentalitros DECIMAL(18,2) NOT NULL," & _
"Medida DECIMAL(18,2) NOT NULL," & _
"Existencia DECIMAL(18,2) NOT NULL," & _
"FechaCorte DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaOrdenDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE OrdenDiesel (" & _
"IdOrden INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"IdRuta INTEGER NOT NULL," & _
"IdOperador INTEGER NOT NULL," & _
"LstOrden DECIMAL(18,2) NOT NULL," & _
"LstDesp DECIMAL(18,2) NOT NULL," & _
"Observaciones VARCHAR(500) NOT NULL," & _
"FechaOrden DATETIME NOT NULL," & _
"FechaSurtido DATETIME NOT NULL," & _
"Usuario VARCHAR(50) NOT NULL," & _
"Status VARCHAR(1) NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaKilometros()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Kilometros (" & _
"IdKms INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"Odometro DECIMAL(18,2) NOT NULL," & _
"Kms DECIMAL(18,2) NOT NULL," & _
"Ejercicio INTEGER NOT NULL," & _
"Periodo INTEGER NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaSabanasBoletosSobrantes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE SabanasBoletosSobrantes (" & _
"IdSobrante INTEGER IDENTITY NOT NULL," & _
"Analista VARCHAR(200) NOT NULL," & _
"Operador VARCHAR(200) NOT NULL," & _
"Autobus VARCHAR(20) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"CantidadOriginal INTEGER NOT NULL," & _
"CantidadModificada INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaSabanasEnvios()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE SabanasEnvios (" & _
"IdEnvio INTEGER IDENTITY NOT NULL," & _
"Ubicacion VARCHAR(200) NOT NULL," & _
"Fecha DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaValidacionesPagobus()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE ValidacionesPagobus (" & _
"IdValidacion INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Empresa INTEGER NOT NULL," & _
"Nombre VARCHAR(200) NOT NULL," & _
"MovEfectivo DECIMAL(18,2) NOT NULL," & _
"MovPreferencial DECIMAL(18,2) NOT NULL," & _
"MovGeneral DECIMAL(18,2) NOT NULL," & _
"ImportePreferencial DECIMAL(18,2) NOT NULL," & _
"ImporteGeneral DECIMAL(18,2) NOT NULL," & _
"ImporteEfectivo DECIMAL(18,2) NOT NULL," & _
"ImporteTotal DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaInfoTroncalServiciosReales()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE InfoTroncalServiciosReales (" & _
"IdServicio INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Empresa VARCHAR(200) NOT NULL," & _
"L1 DECIMAL(18,2) NOT NULL," & _
"L2 DECIMAL(18,2) NOT NULL," & _
"L3 DECIMAL(18,2) NOT NULL," & _
"L4 DECIMAL(18,2) NOT NULL," & _
"L5 DECIMAL(18,2) NOT NULL," & _
"L6 DECIMAL(18,2) NOT NULL," & _
"L7 DECIMAL(18,2) NOT NULL," & _
"L8 DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL," & _
"L_1 DECIMAL(18,2) NOT NULL," & _
"L_2 DECIMAL(18,2) NOT NULL," & _
"L_3 DECIMAL(18,2) NOT NULL," & _
"L_4 DECIMAL(18,2) NOT NULL," & _
"L_5 DECIMAL(18,2) NOT NULL," & _
"L_6 DECIMAL(18,2) NOT NULL," & _
"L_7 DECIMAL(18,2) NOT NULL," & _
"L_8 DECIMAL(18,2) NOT NULL," & _
"Total_ DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaInfoTroncalServiciosVacios()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE InfoTroncalServiciosVacios (" & _
"IdServicio INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Empresa VARCHAR(200) NOT NULL," & _
"L1 DECIMAL(18,2) NOT NULL," & _
"L2 DECIMAL(18,2) NOT NULL," & _
"L3 DECIMAL(18,2) NOT NULL," & _
"L4 DECIMAL(18,2) NOT NULL," & _
"L5 DECIMAL(18,2) NOT NULL," & _
"L6 DECIMAL(18,2) NOT NULL," & _
"L7 DECIMAL(18,2) NOT NULL," & _
"L8 DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL," & _
"L_1 DECIMAL(18,2) NOT NULL," & _
"L_2 DECIMAL(18,2) NOT NULL," & _
"L_3 DECIMAL(18,2) NOT NULL," & _
"L_4 DECIMAL(18,2) NOT NULL," & _
"L_5 DECIMAL(18,2) NOT NULL," & _
"L_6 DECIMAL(18,2) NOT NULL," & _
"L_7 DECIMAL(18,2) NOT NULL," & _
"L_8 DECIMAL(18,2) NOT NULL," & _
"Total_ DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaInfoTroncalServiciosProgramados()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE InfoTroncalServiciosProgramados (" & _
"IdServicio INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Empresa VARCHAR(200) NOT NULL," & _
"L1 DECIMAL(18,2) NOT NULL," & _
"L2 DECIMAL(18,2) NOT NULL," & _
"L3 DECIMAL(18,2) NOT NULL," & _
"L4 DECIMAL(18,2) NOT NULL," & _
"L5 DECIMAL(18,2) NOT NULL," & _
"L6 DECIMAL(18,2) NOT NULL," & _
"L7 DECIMAL(18,2) NOT NULL," & _
"L8 DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL," & _
"L_1 DECIMAL(18,2) NOT NULL," & _
"L_2 DECIMAL(18,2) NOT NULL," & _
"L_3 DECIMAL(18,2) NOT NULL," & _
"L_4 DECIMAL(18,2) NOT NULL," & _
"L_5 DECIMAL(18,2) NOT NULL," & _
"L_6 DECIMAL(18,2) NOT NULL," & _
"L_7 DECIMAL(18,2) NOT NULL," & _
"L_8 DECIMAL(18,2) NOT NULL," & _
"Total_ DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaInfoTroncalMovilidad()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE InfoTroncalMovilidad (" & _
"IdMovilidad INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Tarifa VARCHAR(200) NOT NULL," & _
"SITI DECIMAL(18,2) NOT NULL," & _
"SITN DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaInfoTroncalIngreso()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE InfoTroncalIngreso (" & _
"IdIngreso INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Tarifa VARCHAR(200) NOT NULL," & _
"SITI DECIMAL(18,2) NOT NULL," & _
"SITN DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaInfoAXR()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE InfoA_X_R (" & _
"IdInfo INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Empresa INTEGER NOT NULL," & _
"NombreEmpresa VARCHAR(200) NOT NULL," & _
"Ruta VARCHAR(100) NOT NULL," & _
"NombreRuta VARCHAR(200) NOT NULL," & _
"TipoRuta VARCHAR(100) NOT NULL," & _
"Longitud DECIMAL(18,2) NOT NULL," & _
"Efectivo DECIMAL(18,2) NOT NULL," & _
"T_General DECIMAL(18,2) NOT NULL," & _
"T_Preferencial DECIMAL(18,2) NOT NULL," & _
"Transbordos DECIMAL(18,2) NOT NULL," & _
"Vueltas DECIMAL(18,2) NOT NULL," & _
"Unidades DECIMAL(18,2) NOT NULL," & _
"PlanEmpresa VARCHAR(100) NOT NULL," & _
"BoletosXBloqueo DECIMAL(18,2) NOT NULL," & _
"MovilidadTotalPagobus DECIMAL(18,2) NOT NULL," & _
"VueltasProgramadas DECIMAL(18,2) NOT NULL," & _
"TipoProgramacion VARCHAR(100) NOT NULL," & _
"Longitud_ DECIMAL(18,2) NOT NULL," & _
"Kms_Prog DECIMAL(18,2) NOT NULL," & _
"Km_Reales DECIMAL(18,2) NOT NULL," & _
"IPK DECIMAL(18,2) NOT NULL," & _
"Observaciones VARCHAR(200) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaReporteGeneral()
        Dim Sql As String = "USE " & "Movilidad" & vbCrLf & _
"CREATE TABLE ReporteGeneral (" & _
"IdReporte INTEGER IDENTITY NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"No INTEGER NOT NULL," & _
"Empresa VARCHAR(200) NOT NULL," & _
"Mov_A DECIMAL(18,2) NOT NULL," & _
"Mov_X DECIMAL(18,2) NOT NULL," & _
"Mov_R DECIMAL(18,2) NOT NULL," & _
"Km_A_X_R_Realizados DECIMAL(18,2) NOT NULL," & _
"_Km_A_X_R DECIMAL(18,2) NOT NULL," & _
"_Part_A_X_R DECIMAL(18,2) NOT NULL," & _
"MovTroncal DECIMAL(18,2) NOT NULL," & _
"KmTroncalRealizados DECIMAL(18,2) NOT NULL," & _
"_KmTroncalRealizados DECIMAL(18,2) NOT NULL," & _
"_PartTroncal DECIMAL(18,2) NOT NULL," & _
"IngresoEfectivoA_X_R DECIMAL(18,2) NOT NULL," & _
"IngresoTarjetaA_X_R DECIMAL(18,2) NOT NULL," & _
"IngresoPor_PartA_X_R DECIMAL(18,2) NOT NULL," & _
"AjusteVentaVsParticipacion DECIMAL(18,2) NOT NULL," & _
"RepartoTarjetaA_X_RAjustado DECIMAL(18,2) NOT NULL," & _
"RetencionA_X_RPagobus DECIMAL(18,2) NOT NULL," & _
"TotalA_X_RDeposito DECIMAL(18,2) NOT NULL," & _
"AdeudoGenerado DECIMAL(18,2) NOT NULL," & _
"IngresosTroncalEfTarjeta DECIMAL(18,2) NOT NULL," & _
"RetencionTroncalPagobus DECIMAL(18,2) NOT NULL," & _
"TotalTroncalDeposito DECIMAL(18,2) NOT NULL," & _
"MovilidadTotal DECIMAL(18,2) NOT NULL," & _
"IngresoTotal DECIMAL(18,2) NOT NULL," & _
"TotalDepositar DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=Movilidad;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCot_SolicitudDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Cot_SolicitudDetalle (" & _
"IdDetalle INTEGER IDENTITY NOT NULL," & _
"IdSolicitud INTEGER NOT NULL," & _
"IdProducto INTEGER NOT NULL," & _
"Cantidad DECIMAL(18,2) NOT NULL," & _
"IdAlmacen INTEGER NOT NULL," & _
"Estado INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCot_Solicitud()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Cot_Solicitud (" & _
"IdSolicitud INTEGER IDENTITY NOT NULL," & _
"Folio INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Solicita VARCHAR(300) NOT NULL," & _
"Estado INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCot_Anexos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Cot_Anexos (" & _
"IdAnexo INTEGER IDENTITY NOT NULL," & _
"IdGeneral INTEGER NOT NULL," & _
"Anexo IMAGE NOT NULL," & _
"Nombre VARCHAR(300) NOT NULL," & _
"Extencion VARCHAR(10) NOT NULL," & _
"Descripcion VARCHAR(300) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCot_Detalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
     "CREATE TABLE Cot_Detalle (" & _
     "IdDetalle INTEGER IDENTITY NOT NULL, " & _
     "IdGeneral INTEGER NOT NULL," & _
     "idProducto INTEGER NOT NULL," & _
     "Codigo VARCHAR(20) NOT NULL," & _
     "Producto VARCHAR(300) NOT NULL," & _
     "Cantidad DECIMAL(18,2) NOT NULL," & _
     "PU DECIMAL(18,2) NOT NULL," & _
     "Subtotal DECIMAL(18,2) NOT NULL," & _
     "IVA DECIMAL(18,2) NOT NULL," & _
     "Total DECIMAL(18,2) NOT NULL)"


        '"Vehiculo VARCHAR(50) NOT NULL," & _
        '"Fecha DateTime," & _
        '"Kilometros DECIMAL(18,2))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCot_Generales()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
      "CREATE TABLE Cot_Generales (" & _
      "IdGeneral INTEGER IDENTITY NOT NULL, " & _
      "IdDocumento INTEGER NOT NULL," & _
      "IdProveedor INTEGER NOT NULL," & _
      "Codigo VARCHAR(20) NOT NULL," & _
      "RazonSocial VARCHAR(300) NOT NULL," & _
      "NoCotizacion INTEGER NOT NULL," & _
      "Subtotal DECIMAL(18,2) NOT NULL," & _
      "IVA DECIMAL(18,2) NOT NULL," & _
      "Total DECIMAL(18,2) NOT NULL)"


        '"Vehiculo VARCHAR(50) NOT NULL," & _
        '"Fecha DateTime," & _
        '"Kilometros DECIMAL(18,2))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCot_Documentos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
       "CREATE TABLE Cot_Documentos (" & _
       "IdDocumento INTEGER IDENTITY NOT NULL, " & _
       "Folio INTEGER NOT NULL," & _
       "Fecha DATETIME NOT NULL," & _
       "NoCotizaciones INTEGER NOT NULL," & _
       "Procesada INTEGER NOT NULL," & _
       "Concepto VARCHAR(200) NOT NULL)"


        '"Vehiculo VARCHAR(50) NOT NULL," & _
        '"Fecha DateTime," & _
        '"Kilometros DECIMAL(18,2))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPrecioVueltasBella()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
   "CREATE TABLE PrecioVueltasBella (" & _
"IdPrecio INTEGER IDENTITY NOT NULL, " & _
"IdRuta INTEGER NOT NULL," & _
"Precio DECIMAL(18,2) NOT NULL," & _
"Fecha DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaNominasIngreso()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
   "CREATE TABLE NominasIngreso (" & _
"IdIngreso INTEGER IDENTITY NOT NULL, " & _
"Fecha DATETIME NOT NULL," & _
"Ingreso DECIMAL(18,2) NOT NULL," & _
"Status INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDiasOperacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
    "CREATE TABLE DiasOperacion (" & _
"IdDia INTEGER IDENTITY NOT NULL, " & _
"FechaOperacion DATETIME NOT NULL," & _
"IdRuta INTEGER NOT NULL," & _
"TipoDia INTEGER NOT NULL," & _
"Vueltas DECIMAL(18,2) NOT NULL," & _
"Autobuses INTEGER NOT NULL," & _
"IdNomina INTEGER NOT NULL," & _
"StatusNomina INTEGER NOT NULL," & _
"Usuario VARCHAR(20) NOT NULL," & _
"FechaUltimoCambio DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPlanOperacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
     "CREATE TABLE PlanOperacion (" & _
"IdPlan INTEGER IDENTITY NOT NULL, " & _
"IdRuta INTEGER NOT NULL," & _
"TipoDia INTEGER NOT NULL," & _
"Despachos DECIMAL(18,2) NOT NULL," & _
"Vueltas DECIMAL(18,2) NOT NULL," & _
"Autobuses INTEGER NOT NULL," & _
"Usuario VARCHAR(20) NOT NULL," & _
"FechaUltimoCambio DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CrearBD_skeleton()
        ' La conexión a usar, indicando la base master
        Dim cnn As New SqlConnection

        Try
            ' Abrimos la conexión y ejecutamos el comando
            cnn.ConnectionString = "Server=localhost\SKELETON" & ";database=master;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = "CREATE DATABASE SkeletonDatabase"
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

        Catch ex As SqlException
            MsgBox("Error al crear la base de datos", MsgBoxStyle.Critical, "Aviso")
            MessageBox.Show(ex.Message, _
                            "Error al crear la base", _
                            MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
        End Try


    End Sub
    Sub CreaTablaSKELETON_PasajerosAbordo()
        Dim Sql As String = "USE " & "SkeletonDatabase" & vbCrLf & _
"CREATE TABLE PasajerosAbordo (" & _
"IdPasajero INTEGER NOT NULL," & _
"PASAJEROS VARCHAR(MAX)," & _
"TotalPasajeros VARCHAR (10))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=localhost\SKELETON;database=SkeletonDatabase;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSKELETON_PasajerosBajadaAuxiliar()
        Dim Sql As String = "USE " & "SkeletonDatabase" & vbCrLf & _
"CREATE TABLE PasajerosBajadaAuxiliar (" & _
"IdBajada INTEGER IDENTITY NOT NULL," & _
"IdPasajero INTEGER NOT NULL," & _
"HoraBajada DATETIME NOT NULL," & _
"LongitudBajada VARCHAR(30) NOT NULL," & _
"LatitudBajada VARCHAR(30) NOT NULL," & _
"Cara IMAGE NOT NULL," & _
"NombreCara VARCHAR(50) NOT NULL," & _
"Descargados INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=localhost\SKELETON;database=SkeletonDatabase;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSKELETON_PasajerosBajada()
        Dim Sql As String = "USE " & "SkeletonDatabase" & vbCrLf & _
"CREATE TABLE PasajerosBajada (" & _
"IdBajada INTEGER IDENTITY NOT NULL," & _
"IdPasajero INTEGER NOT NULL," & _
"HoraBajada DATETIME NOT NULL," & _
"LongitudBajada VARCHAR(30) NOT NULL," & _
"LatitudBajada VARCHAR(30) NOT NULL," & _
"Cara IMAGE NOT NULL," & _
"NombreCara VARCHAR(50) NOT NULL," & _
"Descargados INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=localhost\SKELETON;database=SkeletonDatabase;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSKELETON_PasajerosSubida()
        Dim Sql As String = "USE " & "SkeletonDatabase" & vbCrLf & _
"CREATE TABLE PasajerosSubida (" & _
"IdSubuda INTEGER IDENTITY NOT NULL," & _
"IdPasajero INTEGER NOT NULL," & _
"HoraSubida DATETIME NOT NULL," & _
"LongitudSubida VARCHAR(30) NOT NULL," & _
"LatitudSubida VARCHAR(30) NOT NULL," & _
"Cara IMAGE NOT NULL," & _
"NombreCara VARCHAR(50) NOT NULL," & _
"Descargados INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=localhost\SKELETON;database=SkeletonDatabase;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSKELETON_PasajerosRecorrido()
        Dim Sql As String = "USE " & "SkeletonDatabase" & vbCrLf & _
"CREATE TABLE PasajerosRecorrido (" & _
"IdPasajero INTEGER IDENTITY NOT NULL," & _
"Nombre VARCHAR(200) NOT NULL," & _
"HoraSubida DATETIME NOT NULL," & _
"HoraBajada DATETIME NOT NULL," & _
"LongitudSubida VARCHAR(30) NOT NULL," & _
"LatitudSubida VARCHAR(30) NOT NULL," & _
"LongitudBajada VARCHAR(30) NOT NULL," & _
"LatitudBajada VARCHAR(30) NOT NULL," & _
"Cara IMAGE NOT NULL," & _
"NombreCara VARCHAR(50) NOT NULL," & _
"Descargados INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=localhost\SKELETON;database=SkeletonDatabase;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSKELETON_RegistroTR()
        Dim Sql As String = "USE " & "SkeletonDatabase" & vbCrLf & _
"CREATE TABLE RegistroTR (" & _
"IdRegistro INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Subidas INT NOT NULL," & _
"Bajadas INT NOT NULL," & _
"Longitud VARCHAR(50) NOT NULL," & _
"Latitud VARCHAR(50) NOT NULL," & _
"Velocidad DECIMAL(18,2) NOT NULL," & _
"Puerta INT NOT NULL," & _
"PasajerosAbordo INT NOT NULL," & _
"Zona VARCHAR(200) NOT NULL," & _
"Terminal INT NOT NULL," & _
"Descargados INT NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=localhost\SKELETON;database=SkeletonDatabase;user id = SA; password = Skeleton2013IntPassCountBaRcIgKaEt;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSabanasArchivo()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
       "CREATE TABLE SabanasArchivo (" & _
"IdArchivo INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaRecaudacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
       "CREATE TABLE Recaudacion (" & _
"IdRecaudacion INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL," & _
"IdServicio INTEGER NOT NULL," & _
"IdOperador INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Pasajeros INTEGER NOT NULL," & _
"Monto DECIMAL(18,2) NOT NULL," & _
"MarcasDescontadas DECIMAL(18,2) NOT NULL," & _
"MarcasRedondeadas INTEGER NOT NULL," & _
"MontoDeducciones DECIMAL(18,2) NOT NULL," & _
"MontoMenosDeducciones DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaRolesDescuentos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
        "CREATE TABLE RolesDescuentos (" & _
"IdServicio INTEGER IDENTITY NOT NULL, " & _
"Nombre VARCHAR(200) NOT NULL," & _
"Origen VARCHAR(100) NOT NULL, " & _
"Destino VARCHAR(100) NOT NULL," & _
"HoraInicio VARCHAR(100) NOT NULL," & _
"HoraTermino VARCHAR(100) NOT NULL," & _
"TipoDescuento INTEGER NOT NULL," & _
"Marcas INTEGER NOT NULL," & _
"PorcentajeMarcas INTEGER NOT NULL," & _
"PorcentajeDescuento INTEGER NOT NULL," & _
"TipoDia VARCHAR(100) NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSabanasBoletos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE SabanasBoletos (" & _
"IdRegistro INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"Inicial INTEGER NOT NULL," & _
"Final INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSabanas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Sabanas (" & _
"IdSabana INTEGER IDENTITY NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdRuta INTEGER NOT NULL," & _
"NombreRuta VARCHAR(100) NOT NULL," & _
"IdAnalista INTEGER NOT NULL, " & _
"NombreAnalista VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"SalidaReal VARCHAR(10) NOT NULL," & _
"LlegadaReal VARCHAR(10) NOT NULL," & _
"TiempoRecorrido VARCHAR(10) NOT NULL," & _
"Kms DECIMAL(18,2) NOT NULL," & _
"Vueltas DECIMAL(18,2) NOT NULL," & _
"FolioBoletos INTEGER NOT NULL," & _
"Pagobus INTEGER NOT NULL," & _
"VentaPagobus INTEGER NOT NULL," & _
"Transferencias INTEGER NOT NULL," & _
"VentaBoletos INTEGER NOT NULL," & _
"VentaReportada INTEGER NOT NULL," & _
"MovilidadReportada INTEGER NOT NULL," & _
"MovilidadTotal INTEGER NOT NULL," & _
"Tolerancia INTEGER NOT NULL," & _
"MaxAbordo INTEGER NOT NULL," & _
"Bloqueos INTEGER NOT NULL," & _
"BloqueosFaltantes INTEGER NOT NULL," & _
"BoletosPorBloqueos INTEGER NOT NULL," & _
"HoraMaxAbordo VARCHAR(10) NOT NULL," & _
"Observaciones VARCHAR(500) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPagobusDetallado()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE PagobusDetallado (" & _
"IdPagobus INTEGER IDENTITY NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"NoEconomico VARCHAR(50) NOT NULL," & _
"IdOperador INTEGER NOT NULL," & _
"NombreOperador VARCHAR(300) NOT NULL," & _
"Consecutivo INTEGER NOT NULL," & _
"NoServicio INTEGER NOT NULL," & _
"General INTEGER NOT NULL," & _
"Preferencial INTEGER NOT NULL," & _
"Total INTEGER NOT NULL," & _
"IngresoGeneral DECIMAL(18,2) NOT NULL," & _
"IngresoPreferencial DECIMAL(18,2) NOT NULL," & _
"TotalIngreso DECIMAL(18,2))"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaIP()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
        "CREATE TABLE IPScanner (" & _
        "Id INTEGER IDENTITY NOT NULL, " & _
        "IP VARCHAR(100)," & _
        "UBICACION VARCHAR(300))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaTarjetas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
       "CREATE TABLE Tarjetas (" & _
       "IdTarjeta INTEGER IDENTITY NOT NULL," & _
       "CodigoTarjeta VARCHAR(10) NOT NULL," & _
       "IdOperador INTEGER NOT NULL," & _
       "InicioVigencia DATETIME NOT NULL," & _
       "TerminoVigencia DATETIME NOT NULL," & _
       "Status INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAdeudosTradicionales()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE AdeudosTradicionales (" & _
"IdAdeudo INTEGER IDENTITY NOT NULL," & _
"IdCuenta INTEGER NOT NULL," & _
"Codigo VARCHAR(30) NOT NULL," & _
"Nombre VARCHAR(50) NOT NULL," & _
"Tipo VARCHAR(20) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEvaluacionOLDTotales()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EvaluacionOLDTotales (" & _
"IdEvaluacionTotales INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Evaluacion INTEGER NOT NULL," & _
"Mes VARCHAR(20) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Licencia DECIMAL(18,2) NOT NULL," & _
"Tarjeton DECIMAL(18,2) NOT NULL," & _
"Uniforme DECIMAL(18,2) NOT NULL," & _
"Limpieza DECIMAL(18,2) NOT NULL," & _
"Vueltas DECIMAL(18,2) NOT NULL," & _
"Turnos DECIMAL(18,2) NOT NULL," & _
"Frecuencia DECIMAL(18,2) NOT NULL," & _
"Disciplina DECIMAL(18,2) NOT NULL," & _
"Liquidacion DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEvaluacionOLDDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EvaluacionOLDDetalle (" & _
"IdEvaluacionDetalle INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Evaluacion INTEGER NOT NULL," & _
"Mes VARCHAR(20) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Licencia INTEGER NOT NULL," & _
"Tarjeton INTEGER NOT NULL," & _
"Uniforme INTEGER NOT NULL," & _
"Limpieza INTEGER NOT NULL," & _
"Vueltas INTEGER NOT NULL," & _
"Turnos INTEGER NOT NULL," & _
"Frecuencia INTEGER NOT NULL," & _
"Disciplina INTEGER NOT NULL," & _
"Liquidacion INTEGER NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaBiometria()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Biometria (" & _
"IdBiometria INTEGER IDENTITY NOT NULL," & _
"Codigo VARCHAR(20) NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPresupuesto()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Presupuesto (" & _
"IdPresupuesto INTEGER IDENTITY NOT NULL," & _
"Empresa VARCHAR(300) NOT NULL," & _
"Tipo VARCHAR(100) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Enero DECIMAL(18,2)," & _
"Febrero DECIMAL(18,2)," & _
"Marzo DECIMAL(18,2)," & _
"Abril DECIMAL(18,2)," & _
"Mayo DECIMAL(18,2)," & _
"Junio DECIMAL(18,2)," & _
"Julio DECIMAL(18,2)," & _
"Agosto DECIMAL(18,2)," & _
"Septiembre DECIMAL(18,2)," & _
"Octubre DECIMAL(18,2)," & _
"Noviembre DECIMAL(18,2)," & _
"Diciembre DECIMAL(18,2))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
  
    Sub CreaTablaE_Roles()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Roles (" & _
"IdRol INTEGER IDENTITY NOT NULL," & _
"Nombre VARCHAR(100) NOT NULL," & _
"Salida VARCHAR(20) NOT NULL," & _
"Llegada VARCHAR(20) ," & _
"TipoDia VARCHAR(10) NOT NULL," & _
"Encontrado INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Patologias()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Patologias (" & _
"IdPatologia INTEGER IDENTITY NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"IdCatalogo INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Motivo()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Motivo (" & _
"IdMotivo INTEGER IDENTITY NOT NULL," & _
"IdNota INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"IdCatalogo INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Consulta()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Consulta (" & _
"IdConsulta INTEGER IDENTITY NOT NULL," & _
"IdNota INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"AutorizoHuella INTEGER NOT NULL," & _
"Huella IMAGE)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Catalogo()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Catalogo (" & _
"IdCatalogo INTEGER IDENTITY NOT NULL," & _
"Descripcion VARCHAR(500) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Anexos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Anexos (" & _
"IdAnexo INTEGER IDENTITY NOT NULL," & _
"IdNota INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Anexo IMAGE NOT NULL," & _
"Descripcion VARCHAR(500) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Notas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Notas (" & _
"IdNota INTEGER IDENTITY NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Nota VARCHAR(MAX) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Citas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Citas (" & _
"IdCita INTEGER IDENTITY NOT NULL," &
"IdEmpleado INTEGER NOT NULL," & _
"FECHA DATETIME NOT NULL," & _
"HORARIO VARCHAR(5) NOT NULL," & _
"ATENDIDO INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEMI_Global()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EMI_Global (" & _
"Id INTEGER IDENTITY NOT NULL, " & _
"IdEmpleado INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"DM INTEGER NOT NULL," & _
"HAS INTEGER NOT NULL," & _
"TBP INTEGER NOT NULL," & _
"CA INTEGER NOT NULL," & _
"Epilepsia INTEGER NOT NULL," & _
"LUES INTEGER NOT NULL," & _
"VIH INTEGER NOT NULL," & _
"AR INTEGER NOT NULL," & _
"OtrosAHF INTEGER NOT NULL," & _
"Cual VARCHAR(300) NOT NULL, " & _
"Notas VARCHAR(MAX) NOT NULL," & _
"UltimoEmpleo VARCHAR(300) NOT NULL, " & _
"ExposicionContaminantes VARCHAR(300) NOT NULL, " & _
"Accidentestrabajo VARCHAR(300) NOT NULL, " & _
"Balanceada INTEGER NOT NULL," & _
"Equilibrada INTEGER NOT NULL," & _
"Adecuada INTEGER NOT NULL," & _
"Higienica INTEGER NOT NULL," & _
"Suficiente INTEGER NOT NULL," & _
"BanioPersonal VARCHAR(300) NOT NULL, " & _
"Tabaquismo VARCHAR(300) NOT NULL, " & _
"Alcoholismo VARCHAR(300) NOT NULL, " & _
"Toxicomanias VARCHAR(300) NOT NULL, " & _
"Inmunizaciones VARCHAR(300) NOT NULL, " & _
"Deportes VARCHAR(300) NOT NULL, " & _
"TiempoLibre VARCHAR(300) NOT NULL, " & _
"Menarca VARCHAR(300) NOT NULL, " & _
"Ritmo VARCHAR(300) NOT NULL, " & _
"Odinomenorrea VARCHAR(300) NOT NULL, " & _
"FUR VARCHAR(300) NOT NULL, " & _
"VSA VARCHAR(300) NOT NULL, " & _
"Partos VARCHAR(300) NOT NULL, " & _
"PPF VARCHAR(300) NOT NULL, " & _
"CV VARCHAR(300) NOT NULL, " & _
"Mastopatias VARCHAR(300) NOT NULL, " & _
"Papanicolaou VARCHAR(300) NOT NULL, " & _
"OtrosAGO VARCHAR(300) NOT NULL, " & _
"Cefalea VARCHAR(300) NOT NULL, " & _
"Vertigo VARCHAR(300) NOT NULL, " & _
"Dermopatias VARCHAR(300) NOT NULL, " & _
"Atopia VARCHAR(300) NOT NULL, " & _
"Convulsiones VARCHAR(300) NOT NULL, " & _
"Ansiedad VARCHAR(300) NOT NULL, " & _
"Lumbalgia VARCHAR(300) NOT NULL, " & _
"Cirugias VARCHAR(300) NOT NULL, " & _
"Fracturas VARCHAR(300) NOT NULL, " & _
"Transfusionales VARCHAR(300) NOT NULL, " & _
"OtrosAPP VARCHAR(300) NOT NULL, " & _
"PadecimientoActual VARCHAR(MAX) NOT NULL, " & _
"Peso VARCHAR(300) NOT NULL, " & _
"Talla VARCHAR(300) NOT NULL, " & _
"TA VARCHAR(300) NOT NULL, " & _
"FC VARCHAR(300) NOT NULL, " & _
"Cabeza VARCHAR(300) NOT NULL, " & _
"Oidos VARCHAR(300) NOT NULL, " & _
"AV VARCHAR(300) NOT NULL, " & _
"Acromatica VARCHAR(300) NOT NULL," & _
"Nariz VARCHAR(300) NOT NULL, " & _
"Orafaringe VARCHAR(300) NOT NULL, " & _
"Dentadura VARCHAR(300) NOT NULL, " & _
"Cello VARCHAR(300) NOT NULL, " & _
"CSPS VARCHAR(300) NOT NULL, " & _
"RSCS VARCHAR(300) NOT NULL, " & _
"Abdomen VARCHAR(300) NOT NULL, " & _
"Extremidades VARCHAR(300) NOT NULL, " & _
"Columna VARCHAR(300) NOT NULL, " & _
"ROT VARCHAR(300) NOT NULL, " & _
"OtrosEF VARCHAR(300) NOT NULL, " & _
"Estudios VARCHAR(MAX) NOT NULL, " & _
"Diagnostico VARCHAR(MAX) NOT NULL, " & _
"Tratamiento VARCHAR(MAX) NOT NULL, " & _
"Observaciones VARCHAR(MAX) NOT NULL, " & _
"Apto INTEGER NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
   
  
   
    
    Sub CreaTablaE_Porcentajes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Porcentajes (" & _
"IdPorcentaje INTEGER NOT NULL," &
"Servicios DECIMAL(18,2) NOT NULL," & _
"Puntualidad DECIMAL(18,2) NOT NULL," & _
"Presentacion DECIMAL(18,2) NOT NULL," & _
"Rendimiento DECIMAL(18,2) NOT NULL," & _
"Ventas DECIMAL(18,2) NOT NULL," & _
"Bloqueos DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Incentivos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Incentivos (" & _
"IdIncentivo INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Dia1 DECIMAL(18,2) NOT NULL," & _
"Dia2 DECIMAL(18,2) NOT NULL," & _
"Dia3 DECIMAL(18,2) NOT NULL," & _
"Dia4 DECIMAL(18,2) NOT NULL," & _
"Dia5 DECIMAL(18,2) NOT NULL," & _
"Dia6 DECIMAL(18,2) NOT NULL," & _
"Dia7 DECIMAL(18,2) NOT NULL," & _
"Acumulado DECIMAL(18,2) NOT NULL," & _
"FechaInicial DATETIME NOT NULL," & _
"FechaFinal DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_MatrizEvaluacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_MatrizEvaluacion (" & _
"IdMatriz INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Servicios DECIMAL(18,2) NOT NULL," & _
"Puntualidad DECIMAL(18,2) NOT NULL," & _
"Presentacion DECIMAL(18,2) NOT NULL," & _
"Rendimiento DECIMAL(18,2) NOT NULL," & _
"Ventas DECIMAL(18,2) NOT NULL," & _
"Bloqueos DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Productividad()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Productividad (" & _
"IdProductividad INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Liquidacion DECIMAL(18,2) NOT NULL," & _
"Optpcontrol DECIMAL(18,2) NOT NULL," & _
"Cumplimiento DECIMAL(18,2) NOT NULL," & _
"Ventas INTEGER NOT NULL," & _
"Movilidad INTEGER NOT NULL," & _
"Bloqueos INTEGER NOT NULL," & _
"BloqueosPorcentaje DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Ventas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Ventas (" & _
"IdVenta INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"IdLiquidacion INTEGER NOT NULL," & _
"Liquidacion DECIMAL(18,2) NOT NULL," & _
"Optpcontrol DECIMAL(18,2) NOT NULL," & _
"Diferencia DECIMAL(18,2) NOT NULL," & _
"MetaV INTEGER NOT NULL," & _
"Movilidad INTEGER NOT NULL," & _
"Bloqueos INTEGER NOT NULL," & _
"Porcentaje DECIMAL(18,2) NOT NULL," & _
"MetaB INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Diesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Diesel (" & _
"IdDiesel INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Rendimiento INTEGER NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Rendimiento()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Rendimiento (" & _
"IdRendimiento INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"IdDespacho INTEGER NOT NULL," & _
"RendStd DECIMAL(18,2) NOT NULL," & _
"RendReal DECIMAL(18,2) NOT NULL," & _
"Diferencia DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Servicios()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Servicios (" & _
"IdServicio INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Roles INTEGER NOT NULL," & _
"Realizados INTEGER NOT NULL," & _
"Servicios INTEGER NOT NULL," & _
"Minutos INTEGER NOT NULL," & _
"Puntualidad INTEGER NOT NULL," & _
"Presentable INTEGER NOT NULL," & _
"Presentacion INTEGER NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Presentacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Presentacion (" & _
"IdPresentacion INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Presentable INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaE_Despachos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE E_Despachos (" & _
"IdDespacho INTEGER IDENTITY NOT NULL, " & _
"IdAutobus INTEGER NOT NULL, " & _
"NoEconomico VARCHAR(100) NOT NULL, " & _
"IdOperador INTEGER NOT NULL, " & _
"NombreOperador VARCHAR(150) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Rol VARCHAR(150) NOT NULL," & _
"SalidaProg VARCHAR(10) NOT NULL, " & _
"SalidaReal VARCHAR(10) NOT NULL," & _
"Realizado INTEGER NOT NULL," & _
"Justificado INTEGER NOT NULL," & _
"Justificacion VARCHAR(300) NOT NULL," & _
"Minutos DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPorcentajesGeneralesEvaluacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE ParametrosGeneralesEvaluacion (" & _
"Id INTEGER IDENTITY NOT NULL, " & _
"Nombre VARCHAR(100) NOT NULL," & _
"Porcentaje DECIMAL(18,2) NOT NULL) "
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
  
    Sub CreaTablaMovimientosADM()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE MGW10010 (" & _
"Id INTEGER IDENTITY NOT NULL, " & _
"IdMovimiento INTEGER NOT NULL," & _
"IdDocumento INTEGER NOT NULL," & _
"TipoDocumento INTEGER NOT NULL," & _
"NumeroMovimiento INTEGER NOT NULL," & _
"IdProducto INTEGER NOT NULL," & _
"CodigoProducto VARCHAR(30) NOT NULL, " &
"NombreProducto VARCHAR(60) NOT NULL," & _
"NombreAlmacen VARCHAR(60) NOT NULL," & _
"Unidades DECIMAL(18,2) NOT NULL," & _
"Neto DECIMAL(18,2) NOT NULL," & _
"Impuesto1 DECIMAL(18,2) NOT NULL," & _
"Impuesto2 DECIMAL(18,2) NOT NULL," & _
"Impuesto3 DECIMAL(18,2) NOT NULL," & _
"Retencion1 DECIMAL(18,2) NOT NULL," & _
"Retencion2 DECIMAL(18,2) NOT NULL," & _
"Descuento1 DECIMAL(18,2) NOT NULL," & _
"Descuento2 DECIMAL(18,2) NOT NULL," & _
"Descuento3 DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDocumentosADM()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE MGW10008 (" & _
"Id INTEGER IDENTITY NOT NULL, " & _
"IdDocumento INTEGER NOT NULL," & _
"TipoDocumento INTEGER NOT NULL," & _
"NombreConcepto VARCHAR(60) NOT NULL, " &
"Serie VARCHAR(11) NOT NULL," & _
"Folio INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"IdAutobus INTEGER NOT NULL," & _
"NoEconomico VARCHAR(60) NOT NULL," & _
"Referencia VARCHAR(20) NOT NULL," & _
"Observaciones VARCHAR(300) NOT NULL," & _
"Neto DECIMAL(18,2) NOT NULL," & _
"Impuesto1 DECIMAL(18,2) NOT NULL," & _
"Impuesto2 DECIMAL(18,2) NOT NULL," & _
"Impuesto3 DECIMAL(18,2) NOT NULL," & _
"Retencion1 DECIMAL(18,2) NOT NULL," & _
"Retencion2 DECIMAL(18,2) NOT NULL," & _
"Descuento1 DECIMAL(18,2) NOT NULL," & _
"Descuento2 DECIMAL(18,2) NOT NULL," & _
"Descuento3 DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL," & _
"TotalUnidades DECIMAL(18,2) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCuboKilometros()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE CuboKilometros (" & _
"IdKilometro INTEGER IDENTITY NOT NULL, " & _
"Empresa VARCHAR(300) NOT NULL, " &
"Ruta VARCHAR(150) NOT NULL," & _
"IdAutobus INTEGER," & _
"NoInterno VARCHAR(10) NOT NULL," & _
"NoEconomico VARCHAR(20) NOT NULL," & _
"Fecha DateTime NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Cantidad DECIMAL(18,2) NOT NULL," & _
"Tipo VARCHAR(50) NOT NULL," & _
"cIdDocum01 INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCuboContables()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE CuboContables (" & _
"IdContable INTEGER IDENTITY NOT NULL, " & _
"Empresa VARCHAR(300) NOT NULL, " &
"Abreviacion VARCHAR(10) NOT NULL," & _
"Ejercicio INTEGER NOT NULL," & _
"Periodo INTEGER NOT NULL," & _
"Codigo VARCHAR(30) NOT NULL," & _
"Nombre VARCHAR(50) NOT NULL," & _
"Cuenta VARCHAR(90) NOT NULL," & _
"CInforme INTEGER NOT NULL," & _
"CImpuestos INTEGER NOT NULL," & _
"Titulo VARCHAR(90) NOT NULL," & _
"SubTitulo VARCHAR(90) NOT NULL," & _
"Mayor VARCHAR(90) NOT NULL," & _
"IdOriginal INTEGER NOT NULL," & _
"Cargos DECIMAL(18,2) NOT NULL," & _
"Abonos DECIMAL(18,2) NOT NULL," & _
"Saldo DECIMAL(18,2) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCuentasContables()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE CuentasContables (" & _
"IdContable INTEGER IDENTITY NOT NULL, " & _
"Empresa VARCHAR(300) NOT NULL, " &
"Abreviacion VARCHAR(10) NOT NULL," & _
"IdCuenta INTEGER," & _
"Codigo VARCHAR(30) NOT NULL," & _
"Nombre VARCHAR(50) NOT NULL," & _
"Cuenta VARCHAR(90) NOT NULL," & _
"Tipo VARCHAR(1) NOT NULL," & _
"CtaMayor INTEGER NOT NULL," & _
"CInforme INTEGER NOT NULL," & _
"CImpuestos INTEGER NOT NULL," & _
"Titulo VARCHAR(90) NOT NULL," & _
"SubTitulo VARCHAR(90) NOT NULL," & _
"Mayor VARCHAR(90) NOT NULL)"
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCuboIngresos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE CuboIngresos (" & _
"IdIngreso INTEGER IDENTITY NOT NULL, " & _
"Empresa VARCHAR(300) NOT NULL, " &
"Ruta VARCHAR(150) NOT NULL," & _
"IdAutobus INTEGER," & _
"NoInterno VARCHAR(10) NOT NULL," & _
"NoEconomico VARCHAR(20) NOT NULL," & _
"Fecha DateTime NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Cantidad DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL," & _
"Tipo VARCHAR(50) NOT NULL," & _
"cIdDocum01 INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCuboEgresos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE CuboEgresos (" & _
"IdEgreso INTEGER IDENTITY NOT NULL, " & _
"Empresa VARCHAR(300) NOT NULL, " &
"Ruta VARCHAR(150) NOT NULL," & _
"IdAutobus INTEGER," & _
"NoInterno VARCHAR(10) NOT NULL," & _
"NoEconomico VARCHAR(20) NOT NULL," & _
"Fecha DateTime NOT NULL," & _
"Dia INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"CodigoProducto VARCHAR(30) NOT NULL," & _
"NombreProducto VARCHAR(300) NOT NULL," & _
"Cantidad DECIMAL(18,2) NOT NULL," & _
"Neto DECIMAL(18,2) NOT NULL," & _
"IVA DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL," & _
"Tipo VARCHAR(50) NOT NULL," & _
"cIdDocum01 INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDiasTrabajadosDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE DiaTrabajadoDiesel (" & _
          "IdDia INTEGER IDENTITY NOT NULL, " & _
          "Dia INTEGER," & _
          "Mes INTEGER," & _
          "Anio INTEGER)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaKilometrosOperativos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
       "CREATE TABLE KilometrosOperativos (" & _
       "IdAnalisis INTEGER IDENTITY NOT NULL, " & _
       "Vehiculo VARCHAR(50) NOT NULL," & _
       "Fecha DateTime," & _
       "Kilometros DECIMAL(18,2))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDieselSinRecorrido()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
        "CREATE TABLE DieselSinRecorrido (" & _
        "IdDiesel INTEGER IDENTITY NOT NULL, " & _
        "Fecha DateTime," & _
        "IdAutobus INTEGER," & _
        "NoEconomico VARCHAR(50) NOT NULL," & _
        "Litros DECIMAL(18,2)," & _
        "CodigoOperador VARCHAR(50) NOT NULL," & _
        "NombreOperador VARCHAR(150) NOT NULL," & _
        "CodigoDespachador VARCHAR(50) NOT NULL," & _
        "NombreDespachador VARCHAR(150) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaHorariosDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
         "CREATE TABLE HorariosDiesel (" & _
         "IdHorario INTEGER IDENTITY NOT NULL, " & _
         "IdAutobus INTEGER NOT NULL," & _
         "Fecha DATETIME NOT NULL," & _
         "ULTIMA_FECHA_HORA DATETIME NOT NULL)"




        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAgignacionBiometria()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
         "CREATE TABLE AsignacionBiometria (" & _
         "IdBiometria INTEGER IDENTITY NOT NULL, " & _
         "IdEmpleado INTEGER NOT NULL," & _
         "NombreUsuario VARCHAR(50) NOT NULL)"



        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaBiometriaIngreso()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE BiometriaIngreso (" & _
          "IdBiometria INTEGER IDENTITY NOT NULL, " & _
          "IdUsuario INTEGER NOT NULL," & _
          "Template VARBINARY(MAX) NOT NULL," & _
          "Quality INTEGER)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try

    End Sub
    Sub CreaTablaAsignacionServicios()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE AsignacionServicios (" & _
          "IdAsignacion INTEGER IDENTITY NOT NULL, " & _
          "IdServicio INTEGER NOT NULL," &
          "IdSubservicio INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSubServicios()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE SubServicios (" & _
          "IdSubServicio INTEGER IDENTITY NOT NULL, " & _
          "Nombre VARCHAR(100) NOT NULL," &
          "Costo DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaServicios()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Servicios (" & _
          "IdServicio INTEGER IDENTITY NOT NULL, " & _
          "Nombre VARCHAR(100) NOT NULL," &
          "Descripcion VARCHAR(300) NOT NULL," &
          "Frecuencia DECIMAL(18,2) NOT NULL," & _
          "Status INTEGER NOT NULL," & _
          "Costo DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaProductos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Productos (" & _
          "IdProducto INTEGER IDENTITY NOT NULL, " & _
          "CodigoProducto VARCHAR(50) NOT NULL," &
          "Nombre VARCHAR(200) NOT NULL," &
          "NombreMecanico VARCHAR(200) NOT NULL," & _
          "NombreProveedor VARCHAR(200) NOT NULL," & _
          "NombreLargo VARCHAR(300) NOT NULL," & _
          "Descripcion VARCHAR(500) NOT NULL," & _
          "Status INTEGER NOT NULL," & _
          "Familia VARCHAR(100) NOT NULL," & _
          "SubFamilia VARCHAR(100) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablOrdenDetalleProductos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE OrdenDetalleProductos (" & _
          "IdOrden INTEGER IDENTITY NOT NULL, " & _
          "IdMantenimiento INTEGER NOT NULL," &
          "IdProducto INTEGER NOT NULL," &
          "CodigoProducto VARCHAR(50) NOT NULL," & _
          "NombreProducto VARCHAR(200) NOT NULL," & _
          "Cantidad DECIMAL(18,2) NOT NULL," & _
          "PrecioUnitario DECIMAL(18,2) NOT NULL," & _
          "Subtotal DECIMAL(18,2) NOT NULL," & _
          "IVA DECIMAL(18,2) NOT NULL," & _
          "Total DECIMAL(18,2) NOT NULL," & _
          "Almacen VARCHAR(50) NOT NULL," & _
          "NoParte VARCHAR(200) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaOrdenDetalleServicios()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE OrdenDetalleServicios (" & _
          "IdOrden INTEGER IDENTITY NOT NULL, " & _
          "IdMantenimiento INTEGER NOT NULL," &
          "IdServicio INTEGER NOT NULL," &
          "NombreServicio VARCHAR(200) NOT NULL," & _
          "Kilometraje DECIMAL(18,2) NOT NULL," & _
          "Tipo INTEGER NOT NULL," & _
          "Realizado INTEGER NOT NULL," & _
          "DiasDiferencia INTEGER NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaMantenimientos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Mantenimientos (" & _
          "IdMantenimiento INTEGER IDENTITY NOT NULL, " & _
          "Fecha DATETIME NOT NULL," &
          "IdAutobus INTEGER NOT NULL," &
          "NoEconomico VARCHAR(50) NOT NULL," & _
          "IdRuta INTEGER NOT NULL," & _
          "NombreRuta VARCHAR(100) NOT NULL," & _
          "IdOperador INTEGER NOT NULL," & _
          "NombreOperador VARCHAR(200) NOT NULL," & _
          "IdMecanico INTEGER NOT NULL," & _
          "NombreMecanico VARCHAR(200) NOT NULL," & _
          "IdAutoriza INTEGER NOT NULL," & _
          "NombreAutoriza VARCHAR(200) NOT NULL ," & _
          "Observaciones VARCHAR(500) NOT NULL," & _
          "Kilometraje DECIMAL(18,2) NOT NULL," & _
          "Capturo VARCHAR(50) NOT NULL," & _
          "Status INTEGER NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPreventivos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Preventivos (" & _
          "IdPreventivo INTEGER IDENTITY NOT NULL, " & _
          "IdAutobus INTEGER NOT NULL," &
          "NoEconomico Varchar(50) NOT NULL," &
          "IdServicio INTEGER NOT NULL," & _
          "NombreServicio Varchar(200) NOT NULL," & _
          "KmsProgramados DECIMAL(18,2) NOT NULL," & _
          "FechaProgramado DateTime NOT NULL," & _
          "Fecha DateTime NOT NULL)"



        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDieselTemp()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE DieselTemp (" & _
          "IdDiesel INTEGER IDENTITY NOT NULL, " & _
          "IdTanque INTEGER," &
          "NoCarga INTEGER," &
          "Fecha DateTime," & _
          "IdAutobus INTEGER," & _
          "NoEconomico VARCHAR(50) NOT NULL," & _
          "IdRuta INTEGER," & _
          "NombreRuta VARCHAR(100) NOT NULL," & _
          "Litros DECIMAL(18,2)," & _
          "KilometrosTotales DECIMAL(18,2)," & _
          "KilometrosOperacion DECIMAL(18,2)," & _
          "KilometrosMuertos DECIMAL(18,2)," & _
          "Subtotal DECIMAL(18,2)," & _
          "IVA DECIMAL(18,2)," & _
          "Total DECIMAL(18,2))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDiesel()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Diesel (" & _
          "IdDiesel INTEGER IDENTITY NOT NULL, " & _
          "IdTanque INTEGER," &
          "NoCarga INTEGER," &
          "Fecha DateTime," & _
          "Hora DateTime," & _
          "Cuentalitros DECIMAL(18,2)," & _
          "LitrosDisponibles DECIMAL(18,2)," & _
          "Kardex DECIMAL(18,2)," & _
          "Precio DECIMAL(18,2)," & _
          "LitrosSurtidos DECIMAL(18,2)," & _
          "IdAutobus INTEGER," & _
          "NoEconomico VARCHAR(50) NOT NULL," & _
          "IdRuta INTEGER," & _
          "NombreRuta VARCHAR(100) NOT NULL," & _
          "Litros DECIMAL(18,2)," & _
          "KilometrosTotales DECIMAL(18,2)," & _
          "KilometrosOperacion DECIMAL(18,2)," & _
          "KilometrosMuertos DECIMAL(18,2)," & _
          "RendimientoStandart DECIMAL(18,2)," & _
          "RendimientoAnterior DECIMAL(18,2)," & _
          "RendimientoDia DECIMAL(18,2)," & _
          "Subtotal DECIMAL(18,2)," & _
          "IVA DECIMAL(18,2)," & _
          "Total DECIMAL(18,2)," & _
          "CodigoOperador VARCHAR(50) NOT NULL," & _
          "NombreOperador VARCHAR(150) NOT NULL," & _
          "CodigoDespachador VARCHAR(50) NOT NULL," & _
          "NombreDespachador VARCHAR(150) NOT NULL," & _
          "ImporteEx01 DECIMAL(18,2)," & _
          "ImporteEx02 DECIMAL(18,2)," & _
          "ImporteEx03 DECIMAL(18,2)," & _
          "ImporteEx04 DECIMAL(18,2)," & _
          "ImporteEx05 DECIMAL(18,2)," & _
          "TextoEx01 VARCHAR(200) NOT NULL," & _
          "TextoEx02 VARCHAR(200) NOT NULL," & _
          "TextoEx03 VARCHAR(200) NOT NULL," & _
          "TextoEx04 VARCHAR(200) NOT NULL," & _
          "TextoEx05 VARCHAR(200) NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaOperadoresGlobal()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE OperadoresGlobal (" & _
"IdOperador INTEGER IDENTITY NOT NULL," & _
"IdEmpleado INTEGER  NOT NULL," & _
"Codigo VARCHAR(20) NOT NULL," & _
"Nombre VARCHAR(200) NOT NULL," & _
"EstadoEmpleado VARCHAR(1) NOT NULL," & _
"Empresa VARCHAR(20) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn
            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSueldosAcumulados()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE SueldosAcumulados (" & _
"IdSueldo INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"cIdClien01 INTEGER NOT NULL," & _
"cRazonSo01 VARCHAR(100) NOT NULL," & _
"Nomina INTEGER NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Folio INTEGER NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn
            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAbonosFonacot()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE AbonosFonacot (" & _
"IdAbono INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"IdNomina INTEGER NOT NULL," & _
"Mes INTEGER NOT NULL," & _
"Periodo INTEGER NOT NULL," & _
"Monto DECIMAL(18,2) NOT NULL," & _
"Anio INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAbonosInfonavit()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE AbonosInfonavit (" & _
"IdAbono INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"IdNomina INTEGER NOT NULL," & _
"Bimestre INTEGER NOT NULL," & _
"Periodo INTEGER NOT NULL," & _
"Monto DECIMAL(18,2) NOT NULL," & _
"Anio INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaNominaDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE NominaDetalle (" & _
"IdDetalle INTEGER NOT NULL," & _
"IdNomina INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Codigo VARCHAR(20) NOT NULL," & _
"Nombre VARCHAR(200) NOT NULL," & _
"Ingreso DECIMAL(18,2) NOT NULL," & _
"Dias DECIMAL(18,2) NOT NULL," & _
"Sueldo DECIMAL(18,2) NOT NULL," & _
"Ayuda DECIMAL(18,2) NOT NULL," & _
"Comedor DECIMAL(18,2) NOT NULL," & _
"Horas DECIMAL(18,2) NOT NULL," & _
"Deporte DECIMAL(18,2) NOT NULL," & _
"Puntualidad DECIMAL(18,2) NOT NULL," & _
"Asistencia DECIMAL(18,2) NOT NULL," & _
"Gratificacion DECIMAL(18,2) NOT NULL," & _
"Percepciones DECIMAL(18,2) NOT NULL," & _
"ISR DECIMAL(18,2) NOT NULL," & _
"IMSS DECIMAL(18,2) NOT NULL," & _
"Infonavit DECIMAL(18,2) NOT NULL," & _
"Fonacot DECIMAL(18,2) NOT NULL," & _
"Deducciones DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaNominaGeneral()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE NominaGeneral (" & _
"IdNomina INTEGER NOT NULL," & _
"Folio INTEGER NOT NULL," & _
"Infonavit INTEGER NOT NULL," & _
"Fonacot VARCHAR(10) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Nomina INTEGER NOT NULL," & _
"Columnas INTEGER NOT NULL," & _
"FechaInicial DATETIME NOT NULL," & _
"FechaFinal DATETIME NOT NULL," & _
"FechaAplicacion DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPrecioVueltas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE PrecioVueltas (" & _
"IdRuta INTEGER NOT NULL," & _
"Precio DECIMAL(18,2) NOT NULL," & _
"Abre VARCHAR(20) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaSalariosMinimos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE SalariosMinimos (" & _
"IdSM INTEGER NOT NULL," & _
"Zona VARCHAR(1) NOT NULL," & _
"Monto DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEvaluacioTotales()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EvaluacionTotales (" & _
"IdEvaluacionTotales INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Evaluacion INTEGER NOT NULL," & _
"Mes VARCHAR(10) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Licencia DECIMAL(18,2) NOT NULL," & _
"Tarjeton DECIMAL(18,2) NOT NULL," & _
"Uniforme DECIMAL(18,2) NOT NULL," & _
"Limpieza DECIMAL(18,2) NOT NULL," & _
"Vueltas DECIMAL(18,2) NOT NULL," & _
"Turnos DECIMAL(18,2) NOT NULL," & _
"Frecuencia DECIMAL(18,2) NOT NULL," & _
"Disciplina DECIMAL(18,2) NOT NULL," & _
"Liquidacion DECIMAL(18,2) NOT NULL," & _
"Rendimiento DECIMAL(18,2) NOT NULL," & _
"Cuidado DECIMAL(18,2) NOT NULL," & _
"Manejo DECIMAL(18,2) NOT NULL," & _
"Trato DECIMAL(18,2) NOT NULL," & _
"Disponibilidad DECIMAL(18,2) NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEvaluacionDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EvaluacionDetalle (" & _
"IdEvaluacionDetalle INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Evaluacion INTEGER NOT NULL," & _
"Mes VARCHAR(10) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Licencia INTEGER NOT NULL," & _
"Tarjeton INTEGER NOT NULL," & _
"Uniforme INTEGER NOT NULL," & _
"Limpieza INTEGER NOT NULL," & _
"Vueltas INTEGER NOT NULL," & _
"Turnos INTEGER NOT NULL," & _
"Frecuencia INTEGER NOT NULL," & _
"Disciplina INTEGER NOT NULL," & _
"Liquidacion INTEGER NOT NULL," & _
"Rendimiento INTEGER NOT NULL," & _
"Cuidado INTEGER NOT NULL," & _
"Manejo INTEGER NOT NULL," & _
"Trato INTEGER NOT NULL," & _
"Disponibilidad INTEGER NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEvaluacionInternaTotales()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EvaluacionInternaTotales (" & _
"IdEvaluacionInternaTotales INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Mes VARCHAR(10) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Total DECIMAL(18,2) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEvaluacionInternaDetalle()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE EvaluacionInternaDetalle (" & _
"IdEvaluacionInternaDetalle INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Evaluacion INTEGER NOT NULL," & _
"Mes VARCHAR(10) NOT NULL," & _
"Anio INTEGER NOT NULL," & _
"Rendimiento INTEGER NOT NULL," & _
"Cuidado INTEGER NOT NULL," & _
"Manejo INTEGER NOT NULL," & _
"Usuario VARCHAR(10) NOT NULL," & _
"Disponible INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub

    Sub CreaTablaUniformes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Uniformes (" & _
"IdUniforme INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"TallaPantalon VARCHAR(10) NOT NULL," & _
"CantidadPantalon INTEGER NOT NULL," & _
"TallaCamisa VARCHAR(10) NOT NULL," & _
"CantidadCamisa INTEGER NOT NULL," & _
"TallaGorro VARCHAR(10) NOT NULL," & _
"CantidadGorro INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCapacitacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Capacitacion (" & _
"IdCapacitacion INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Tarjeton VARCHAR(10) NOT NULL," & _
"Tipo VARCHAR(10) NOT NULL," & _
"Modulo VARCHAR(15) NOT NULL," & _
"FechaExpedicion DATETIME NOT NULL," & _
"FechaExpira DATETIME NOT NULL," & _
"FechaRecibe DATETIME NOT NULL," & _
"Status VARCHAR(10) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaFactores()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Factores (" & _
          "IdFactor INTEGER NOT NULL, " & _
          "Antiguedad INTEGER," & _
          "Factor DECIMAL(18,4))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDiasTrabajadoPagobus()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE DiaTrabajadoPagobus (" & _
          "IdDia INTEGER IDENTITY NOT NULL, " & _
          "Dia INTEGER," & _
          "Mes INTEGER," & _
          "Anio INTEGER)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPagobus()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Pagobus (" & _
          "IdLiquidacion INTEGER IDENTITY NOT NULL, " & _
          "Fecha DateTime," & _
          "IdAutobus INTEGER," & _
          "NoEconomico VARCHAR(30) NOT NULL," & _
          "IdRuta INTEGER," & _
          "NombreRuta VARCHAR(100) NOT NULL," & _
          "Preferencial DECIMAL(18,2)," & _
          "General DECIMAL(18,2)," & _
          "Validaciones DECIMAL(18,2)," & _
          "IngresoPreferencial DECIMAL(18,2)," & _
          "IngresoGeneral DECIMAL(18,2)," & _
          "IngresoValidaciones DECIMAL(18,2)," & _
          "Importe01 DECIMAL(18,2)," & _
          "Importe02 DECIMAL(18,2)," & _
          "Importe03 DECIMAL(18,2)," & _
          "Importe04 DECIMAL(18,2)," & _
          "Importe05 DECIMAL(18,2)," & _
          "Texto01 VARCHAR(100)," & _
          "Texto02 VARCHAR(100)," & _
          "Texto03 VARCHAR(100)," & _
          "Texto04 VARCHAR(100)," & _
          "Texto05 VARCHAR(100))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAltas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Altas (" & _
"IdAlta INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL," & _
"Usuario VARCHAR(20) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaLicencias()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Licencias (" & _
"IdEmpleado INTEGER NOT NULL," & _
"Licencia VARCHAR(20) NOT NULL," & _
"Tipo VARCHAR(10) NOT NULL," & _
"Vigencia DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaFianzas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Fianzas (" & _
"IdEmpleado INTEGER NOT NULL," & _
"Fianza DECIMAL(18,2) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Capturo VARCHAR(20) NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaGafetes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Gafetes (" & _
"IdEmpleado INTEGER NOT NULL," & _
"Vence DATETIME NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaBajas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Bajas (" & _
"IdBaja INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"FechaBaja DATETIME NOT NULL," & _
"CausaBaja VARCHAR(200) NOT NULL," & _
"Capturo VARCHAR(20) NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL," & _
"Finiquito VARCHAR(200) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaObservaciones()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Observaciones (" & _
"IdObservacion INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Observacion VARCHAR(400) NOT NULL," & _
"Capturo VARCHAR(20) NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL," & _
"Fecha datetime NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaOtrosCargos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE OtrosCargos (" & _
"IdCargo INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Motivo VARCHAR(200) NOT NULL," & _
"Monto  DECIMAL(18,2) NOT NULL," & _
"Tiempo INTEGER NOT NULL," & _
"Tipo VARCHAR(20) NOT NULL," & _
"Descuento  DECIMAL(18,2) NOT NULL," & _
"Capturo VARCHAR(20) NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL," & _
"Fecha datetime NOT NULL," & _
"FechaRegistro datetime NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaMovimientos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Movimientos (" & _
"IdMovimiento INTEGER NOT NULL," & _
"IdAdeudo INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"IdNomina INTEGER NOT NULL," & _
"Fecha datetime NOT NULL," & _
"Monto  DECIMAL(18,2) NOT NULL," & _
"Tipo INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAdeudos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Adeudos (" & _
"IdAdeudo INTEGER NOT NULL," & _
"Nombre VARCHAR(50) NOT NULL," & _
"Aplicacion INTEGER NOT NULL," & _
"Descuento INTEGER NOT NULL," & _
"Cantidad DECIMAL(18,2) NOT NULL," & _
"Prioridad INTEGER NOT NULL," & _
"IdConcepto INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPermisos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Permisos (" & _
"IdPermiso INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Dia DATETIME NOT NULL," & _
"Horario VARCHAR(50) NOT NULL," & _
"Tipo VARCHAR(25) NOT NULL," & _
"Observaciones VARCHAR(100) NOT NULL," & _
"Capturo VARCHAR(20) NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaVacaciones()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Vacaciones (" & _
"IdVacacion INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"TomaFechaInicial DATETIME NOT NULL," &
"TomaFechaFinal DATETIME NOT NULL," &
"EsFechaInicial DATETIME NOT NULL," &
"EsFechaFinal DATETIME NOT NULL," &
"Periodo VARCHAR(20) NOT NULL," & _
"Observaciones VARCHAR(100) NOT NULL," & _
"Capturo VARCHAR(20) NOT NULL," & _
"Reportado VARCHAR(10) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaGratificaciones()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Gratificaciones (" & _
"IdGratificacion INTEGER NOT NULL," & _
"IdEmpleado INTEGER NOT NULL," & _
"Departamento VARCHAR(30) NOT NULL," & _
"Tipo VARCHAR(15) NOT NULL," & _
"Monto DECIMAL(18,2) NOT NULL," & _
"Motivo VARCHAR(200) NOT NULL," & _
"Usuario VARCHAR(200) NOT NULL," & _
"Fecha DATETIME NOT NULL," & _
"Notificado VARCHAR(10) NOT NULL," & _
"TipoHora VARCHAR(10) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAccidentes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
 "CREATE TABLE Accidentes (" & _
 "IdAccidente INTEGER NOT NULL," & _
 "IdEmpleado INTEGER NOT NULL," & _
 "Fecha DATETIME NOT NULL," & _
 "Hora VARCHAR(10) NOT NULL," & _
 "Lugar VARCHAR(80) NOT NULL," & _
 "Responsabilidad VARCHAR(10) NOT NULL," & _
 "Severidad VARCHAR(10) NOT NULL," & _
 "Monto DECIMAL(18,2) NOT NULL," & _
 "Cobro DECIMAL(18,2) NOT NULL," & _
 "Ruta VARCHAR(100) NOT NULL," & _
 "Autobus VARCHAR(20) NOT NULL," & _
 "Causa VARCHAR(200) NOT NULL," & _
 "Usuario VARCHAR(20) NOT NULL," & _
 "Tipo VARCHAR(15) NOT NULL," & _
 "Reportado VARCHAR(10) NOT NULL," & _
 "Enviado VARCHAR(10) NOT NULL," & _
 "Folio VARCHAR(10) NOT NULL," & _
 "Destino VARCHAR(20) NOT NULL," & _
 "FechaRegistro DATETIME NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaReportes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE Reportes (" & _
  "IdReporte INTEGER NOT NULL," & _
  "IdConsecutivo INTEGER NOT NULL," & _
  "IdEmpleado INTEGER NOT NULL," & _
  "Fecha DATETIME NOT NULL," & _
  "Motivo VARCHAR(100) NOT NULL," & _
  "Resolucion VARCHAR(200) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaInfonavitFonacot()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE InfonavitFonacot (" & _
  "IdRegistro INTEGER NOT NULL," & _
  "IdEmpleado INTEGER NOT NULL," & _
  "Fecha DATETIME NOT NULL," & _
  "Original DECIMAL(18,2) NOT NULL," & _
  "Nuevo DECIMAL(18,2) NOT NULL," & _
  "Motivo VARCHAR(200) NOT NULL," & _
  "Capturo VARCHAR(200) NOT NULL," & _
  "Reportado VARCHAR(200) NOT NULL," & _
  "Tipo VARCHAR(200) NOT NULL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCargosFonacot()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE CargosFonacot (" & _
  "IdCargoFonacot INTEGER NOT NULL," & _
  "IdEmpleado INTEGER NOT NULL," & _
  "Monto DECIMAL(18,2) NOT NULL," & _
  "Mes INTEGER NOT NULL," & _
  "Anio INTEGER NOT NULL," & _
  "Fecha DATETIME NOT NULL) "


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaCargosInfonavit()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE CargosInfonavit (" & _
  "IdCargoInfonavit INTEGER NOT NULL," & _
  "IdEmpleado INTEGER NOT NULL," & _
  "Monto DECIMAL(18,2) NOT NULL," & _
  "Bimestre INTEGER NOT NULL," & _
  "Anio INTEGER NOT NULL," & _
  "Fecha DATETIME NOT NULL) "


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaMeses()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE PeriodoFonacot (" & _
  "IdFonacot INTEGER NOT NULL," & _
  "Mes INTEGER NOT NULL," & _
  "Del INTEGER NOT NULL," & _
  "Al INTEGER NOT NULL," & _
  "Anio INTEGER NOT NULL," & _
  "Status VARCHAR(10) NOT NULL) "


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaBimestres()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE PeriodoInfonavit (" & _
  "IdInfonavit INTEGER NOT NULL," & _
  "Bimestre INTEGER NOT NULL," & _
  "Del INTEGER NOT NULL," & _
  "Al INTEGER NOT NULL," & _
  "Anio INTEGER NOT NULL," & _
  "Status VARCHAR(10) NOT NULL) "


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaIncapacidades()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
  "CREATE TABLE Incapacidades (" & _
  "IdIncapacidad INTEGER NOT NULL," & _
  "Folio INTEGER NOT NULL," & _
  "Serie VARCHAR(10) NOT NULL, " & _
  "IdEmpleado INTEGER NOT NULL, " & _
  "Nombre VARCHAR(200) NOT NULL, " & _
  "NSS VARCHAR(20) NOT NULL," & _
  "Motivo VARCHAR(20) NOT NULL, " & _
  "Tipo VARCHAR(20) NOT NULL, " & _
  "FechaInicio DATETIME, " & _
  "Dias INTEGER NOT NULL," & _
  "FechaFin DATETIME," & _
  "Descripcion VARCHAR(20) ," & _
  "Reportado VARCHAR(10) NOT NULL," & _
  "ReportadoT VARCHAR(20) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPeriodos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Periodos (" & _
"IdPeriodo INTEGER NOT NULL, " & _
"Nombre VARCHAR(100))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaTurnos()

        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Turnos (" & _
"IdTurno INTEGER NOT NULL, " & _
"Numero INTEGER, " & _
"Descripcion VARCHAR(100))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaPuestos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Puestos (" & _
"IdPuesto INTEGER NOT NULL, " & _
"Numero INTEGER, " & _
"Descripcion VARCHAR(100))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDepartamentos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
"CREATE TABLE Departamentos (" & _
"IdDepartamento INTEGER NOT NULL, " & _
"Numero INTEGER, " & _
"Descripcion VARCHAR(100))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEmpleados()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
    "CREATE TABLE Empleados (" & _
    "IdEmpleado INTEGER NOT NULL, " & _
    "IdDepartamento INTEGER, " & _
    "IdPuesto INTEGER, " & _
    "IdPeriodo INTEGER, " & _
    "IdTurno INTEGER, " & _
    "Codigo VARCHAR(50) NOT NULL," & _
    "Nombre VARCHAR(50) NOT NULL, " & _
    "ApellidoPaterno VARCHAR(50) NOT NULL, " & _
    "ApellidoMaterno VARCHAR(50) NOT NULL, " & _
    "NombreCompleto VARCHAR(150) NOT NULL, " & _
    "FechaNacimiento DATETIME, " & _
    "LugarNacimiento VARCHAR(100) NOT NULL, " & _
    "EstadoCivil VARCHAR(1) NOT NULL, " & _
    "Sexo VARCHAR(1) NOT NULL, " & _
    "CURP VARCHAR(4) NOT NULL, " & _
    "CURPF VARCHAR(8) NOT NULL, " & _
    "NSS VARCHAR(20) NOT NULL," & _
    "RFC VARCHAR(4) NOT NULL, " & _
    "Homoclave VARCHAR(3) NOT NULL, " & _
    "CuentaPago VARCHAR(15) NOT NULL," & _
    "Sucursal VARCHAR(30) NOT NULL," & _
    "BancoPago VARCHAR(10) NOT NULL, " & _
    "EstadoEmpleado VARCHAR(1) NOT NULL, " & _
    "SD FLOAT NOT NULL, " & _
    "FechaSD DATETIME, " & _
    "SDI FLOAT NOT NULL, " & _
    "FechaSDI DATETIME, " & _
    "FechaAlta DATETIME," & _
    "CuentaCW VARCHAR(15) NOT NULL," & _
    "Telefono VARCHAR(20) NOT NULL," & _
    "CodigoPostal VARCHAR(10) NOT NULL," & _
    "Direccion VARCHAR(200) NOT NULL," & _
    "Poblacion VARCHAR(50) NOT NULL," & _
    "Estado VARCHAR(50) NOT NULL," & _
    "FechaBaja DATETIME," & _
    "CausaBaja VARCHAR(200) NOT NULL," & _
    "Celular VARCHAR(20) NOT NULL," & _
    "TelefonoRecados VARCHAR(20) NOT NULL," & _
    "Escolaridad VARCHAR(100) NOT NULL," & _
    "FechaReingreso DATETIME," & _
    "PorcentajeDescuento FLOAT," & _
    "Dependientes INTEGER NOT NULL," & _
    "Religion VARCHAR(200) NOT NULL," & _
    "UMF VARCHAR(200) NOT NULL," & _
    "CorreoElectronico VARCHAR(60) NOT NULL," & _
    "TipoRegimen VARCHAR(25) NOT NULL," & _
    "ClabeInterbancaria VARCHAR(30) NOT NULL)"



        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaConceptos()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Conceptos (" & _
          "IdConcepto INTEGER, " & _
          "CodigoConcepto VARCHAR(50) NOT NULL," & _
          "NombreConcepto VARCHAR (200) NOT NULL ," & _
          "CodigoRuta VARCHAR(50) NOT NULL," & _
          "NombreRuta VARCHAR(100) NOT NULL," & _
          "Tipo VARCHAR(50))"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaDiasTrabajadosLiquidacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE DiaTrabajadoLiquidacion (" & _
          "IdDia INTEGER IDENTITY NOT NULL, " & _
          "Dia INTEGER," & _
          "Mes INTEGER," & _
          "Anio INTEGER)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaKardex()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Kardex (" & _
          "IdBoleto INTEGER IDENTITY NOT NULL, " & _
          "IdAutobus INTEGER," & _
          "Serie VARCHAR(1) NOT NULL," & _
          "Inicial DECIMAL," & _
          "Final DECIMAL," & _
          "TotalBoletos DECIMAL)"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            ' MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaLiquidacion()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Liquidacion (" & _
          "IdLiquidacion INTEGER IDENTITY NOT NULL, " & _
          "Fecha DateTime," & _
          "IdLiquidador INTEGER," & _
          "CodigoLiquidador VARCHAR(50) NOT NULL," & _
          "NombreLiquidador VARCHAR(100) NOT NULL," & _
          "IdOperador INTEGER," & _
          "CodigoOperador VARCHAR(50) NOT NULL," & _
          "NombreOperador VARCHAR(100) NOT NULL," & _
          "IdAutobus INTEGER," & _
          "NoEconomico VARCHAR(30) NOT NULL," & _
          "IdRuta INTEGER," & _
          "NombreRuta VARCHAR(100) NOT NULL," & _
          "TipoLiquidacion INTEGER," & _
          "Serie VARCHAR(1) NOT NULL," & _
          "NumeracionInicial DECIMAL," & _
          "NumeracionFinal DECIMAL," & _
          "TotalBoletos DECIMAL," & _
          "Preferencial DECIMAL," & _
          "General DECIMAL," & _
          "IngresoPreferencial DECIMAL," & _
          "IngresoGeneral DECIMAL," & _
          "Vueltas DECIMAL," & _
          "Liquidacion DECIMAL," & _
          "Importe01 DECIMAL," & _
          "Importe02 DECIMAL," & _
          "Importe03 DECIMAL," & _
          "Importe04 DECIMAL," & _
          "Importe05 DECIMAL," & _
          "Texto01 VARCHAR(100)," & _
          "Texto02 VARCHAR(100)," & _
          "Texto03 VARCHAR(100)," & _
          "Texto04 VARCHAR(100)," & _
          "Texto05 VARCHAR(100))"


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaBombas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Bombas (" & _
          "IdBomba INTEGER," & _
          "Nombre VarChar(100) NOT NULL, " & _
          "Ubicacion VarChar(20) NOT NULL, " & _
          "Numeracion_Actual Decimal," & _
          "IdAlmacen INTEGER)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaTanques()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Tanques (" & _
          "IdTanque INTEGER," & _
          "Nombre VarChar(100) NOT NULL, " & _
          "Ubicacion VarChar(100) NOT NULL, " & _
          "Longitud Decimal(18,2)," & _
          "Diametro Decimal(18,2)," & _
          "AltoGlobo Decimal(18,2)," & _
          "Capacidad Decimal(18,2)," & _
          "Medida_Actual Decimal(18,2)," & _
          "IdAlmacen INTEGER," & _
          "IdBomba INTEGER)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAlmacenes()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Almacenes (" & _
          "IdAlmacen INTEGER," & _
          "cCodigoA01 VarChar(20) NOT NULL, " & _
          "cNombreA01 VarChar(100) NOT NULL) "


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            ' MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaAutobuses()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
          "CREATE TABLE Autobuses (" & _
          "IdAutobus INTEGER ," & _
          "NoEconomico VarChar(40) NOT NULL, " & _
          "IdRuta INTEGER, " & _
          "TipoKms INTEGER, " & _
          "Cod_Vehiculo VarChar(20) NOT NULL, " & _
          "Numero_Esclavo VarChar(20) NOT NULL, " & _
          "cIdClien01 INTEGER, " & _
          "cCodigoC01 VarChar(40) NOT NULL, " & _
          "cRazonSo01 VarChar(20) NOT NULL, " & _
          "Placas VarChar(100) NOT NULL, " & _
          "Marca VarChar(100) NOT NULL, " & _
          "Modelo VarChar(50) NOT NULL, " & _
          "Serie VarChar(100) NOT NULL, " & _
          "Motor VarChar(100) NOT NULL, " & _
          "Estatus INTEGER, " & _
          "Importe01 Decimal," & _
          "Importe02 Decimal," & _
          "Importe03 Decimal," & _
          "Importe04 Decimal," & _
          "Importe05 Decimal," & _
          "Texto01 VarChar(300) NOT NULL, " & _
          "Texto02 VarChar(300) NOT NULL, " & _
          "Texto03 VarChar(300) NOT NULL, " & _
          "Texto04 VarChar(300) NOT NULL, " & _
          "Texto05 VarChar(300) NOT NULL) "

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaRutasOpto()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
           "CREATE TABLE RutasOpto (" & _
           "IdRutaOpto INTEGER," & _
           "IdRuta INTEGER, " & _
           "Id_Ruta VarChar(300) NOT NULL, " & _
           "Cod_Ruta VarChar(300) NOT NULL, " & _
           "Descripcion VarChar(300) NOT NULL) "

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaRutas()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
           "CREATE TABLE Rutas (" & _
           "IdRuta INTEGER, " & _
           "Nombre VarChar(300) NOT NULL, " & _
           "Kilometros Decimal," & _
           "cIdValor01 INTEGER," & _
           "cCodigoV01 VarChar(20) NOT NULL," & _
           "cidOpto INTEGER ," & _
           "Imagen VarChar(500) NOT NULL," & _
           "Importe01 Decimal," & _
           "Importe02 Decimal," & _
           "Importe03 Decimal," & _
           "Importe04 Decimal," & _
           "Importe05 Decimal," & _
           "Texto01 VarChar(300) NOT NULL, " & _
           "Texto02 VarChar(300) NOT NULL, " & _
           "Texto03 VarChar(300) NOT NULL, " & _
           "Texto04 VarChar(300) NOT NULL, " & _
           "Texto05 VarChar(300) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            'MsgBox("Tabla creada con exito", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaActividad()
        Dim Sql As String = "USE " & CITRA & vbCrLf & _
            "CREATE TABLE Actividad (" & _
            "Fecha DateTime, " & _
            "Descripcion VarChar(300) NOT NULL, " & _
            "Usuario VarChar(100) NOT NULL, " & _
            "Equipo VarChar(50) NOT NULL, " & _
            "DireccionIP VarChar(20))"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=" & CITRA & ";user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaUsuariosConectados()
        Dim Sql As String = "USE citraGenerales" & vbCrLf & _
            "CREATE TABLE UsuariosConectados (" & _
            "Usuario VarChar(50) NOT NULL, " & _
            "Ubicacion VarChar(100) NOT NULL, " & _
            "Equipo VarChar(100) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()
            MsgBox("La configuración inicial se ha realizado correctamente", MsgBoxStyle.Information, "Aviso")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub InsertaUsuarioPrincipal()
        Dim User As New clsUsuarioPrincipal
        User.IdUsuario = 1
        User.Nombre = "ADMINISTRADOR"
        User.NombreCompleto = "Administrador"
        User.Password = "12345"
        User.InsertarUsuario()
    End Sub
    Sub CreaTablaUsuarios()
        Dim Sql As String = "USE citraGenerales" & vbCrLf & _
             "CREATE TABLE Usuarios (" & _
             "IdUsuario INTEGER, " & _
             "Nombre VarChar(50) NOT NULL, " & _
             "NombreCompleto VarChar(100) NOT NULL, " & _
             "Password VarChar(100) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()


        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEmpresasUsuarios()
        Dim Sql As String = "USE citraGenerales" & vbCrLf & _
             "CREATE TABLE EmpresasUsuarios (" & _
             "IdRegistro INTEGER IDENTITY NOT NULL, " & _
             "IdUsuario INTEGER NOT NULL," & _
             "IdEmpresa INTEGER NOT NULL)"

        
        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()


        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try
    End Sub
    Sub CreaTablaEmpresas()
        Dim Sql As String = "USE citraGenerales" & vbCrLf & _
              "CREATE TABLE Empresas (" & _
              "IdEmpresa INTEGER, " & _
              "Nombre VarChar(100) NOT NULL, " & _
              "BD VarChar(100) NOT NULL, " & _
              "Contabilidad VarChar(100) NOT NULL, " & _
              "Nominas VarChar(100) NOT NULL, " & _
              "AdminPAQ VarChar(200) NOT NULL, " & _
              "Respaldo VarChar(200) NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try

    End Sub
    Sub CreaTablaPermisosUsuarios()
        Dim Sql As String = "USE citraGenerales" & vbCrLf & _
              "CREATE TABLE PermisosUsuarios (" & _
              "IdPermiso INTEGER IDENTITY NOT NULL, " & _
              "IdUsuario INTEGER NOT NULL, " & _
              "IdFormulario INTEGER NOT NULL, " & _
              "Permiso INTEGER NOT NULL)"

        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try

    End Sub
    Sub CreaTablaFormularios()
        Dim Sql As String = "USE citraGenerales" & vbCrLf & _
              "CREATE TABLE Formularios (" & _
              "IdFormulario INTEGER IDENTITY NOT NULL, " & _
              "Nombre VarChar(100) NOT NULL, " & _
              "Tipo VarChar(100) NOT NULL, " & _
              "Formulario VarChar(100) NOT NULL, " & _
              "Familia VarChar(100) NOT NULL, " & _
              "Descripcion VarChar(200) NOT NULL) "


        Dim cnn As New SqlConnection

        Try
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = Sql
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close() ' cierra la conexión  
            End If

        End Try

    End Sub
    Sub CreaCitraGenerales()
        ' La conexión a usar, indicando la base master
        Dim cnn As New SqlConnection

        Try
            ' Abrimos la conexión y ejecutamos el comando
            cnn.ConnectionString = "Server=" & Server & "\COMPAC" & ";database=master;user id = SA; password = Compac123;"
            cnn.Open()

            Dim cmd As New SqlCommand
            cmd.CommandText = "CREATE DATABASE citraGenerales"
            cmd.Connection = cnn

            cmd.ExecuteNonQuery()

            MsgBox("La configuración inicial se ha realizado correctamente", MsgBoxStyle.Information, "Aviso")
        Catch ex As SqlException
            MsgBox("Error al crear la base de datos", MsgBoxStyle.Critical, "Aviso")
            MessageBox.Show(ex.Message, _
                            "Error al crear la base", _
                            MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
        End Try
    End Sub

    Private Sub frmMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Bitacora.RegistraActividad("Cerro el sistema")
        Usuario.EliminaUsuarioConectado()
        Global.System.Windows.Forms.Application.Exit()

    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        chInternet.Checked = False

        Main()

    End Sub
    Sub Main()
        mainOptions.Visible = False
        gsRegPath = "Software\NetSis\Citra"
        Dim key As Microsoft.Win32.RegistryKey
        key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(gsRegPath)
        Server = CType(key.GetValue("Server"), String)
        cIdProdu01 = CType(key.GetValue("cIdProdu01"), Integer)
        CitraInicial = CType(key.GetValue("IniciaCitra"), String)
        'InitialConnection = "Server=" & Server & "\COMPAC" & ";database=citraGenerales;user id = SA; password = Compac123;"
        InitialConnection = "data source = 201.163.91.246; initial catalog = CitraGenerales; user id = sa; password = Ausl4321OPTRA "
        UsuarioActivo = CType(key.GetValue("UsuarioActivo"), String)
        txtUser.Text = UsuarioActivo
        txtPassWord.Text = ""
        txtPassWord.Focus()
        statusEmpresa.Text = "No conectado"
        statusActividad.Text = ": Esperando Password..."

    End Sub

    Private Sub txtPassWord_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPassWord.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
            btnIngresar_Click(Me, System.EventArgs.Empty)
        End If
    End Sub

    Private Sub txtPassWord_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPassWord.TextChanged

    End Sub

    Private Sub btnIngresar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIngresar.Click
        'Verificar
        If txtUser.Text = "" Then
            MsgBox("Debes indicar el nombre de usuario", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If

        If txtPassWord.Text = "" Then
            MsgBox("Debes indicar la contraseña", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If

        If chInternet.Checked = True Then
            InitialConnection = "data source = 201.163.91.243; initial catalog = citraGenerales; user id = SA; password = Ausl4321OPTRA "
            Internet = True

        Else
            InitialConnection = "data source =192.168.254.246; initial catalog = citraGenerales; user id = sa; password = Ausl4321OPTRA "
            Internet = False

        End If

        Dim IDUsuario As Integer = BuscarIntDatoInicial("Select IdUsuario FROM Usuarios Where upper(Nombre)='" & UCase(txtUser.Text.Trim) & "'")
        Dim Password As String = ""

        If IDUsuario > 0 Then
            Password = BuscarStrDatoInicial("Select Password FROM Usuarios WHERE IDUsuario=" & IDUsuario)
            If Password = txtPassWord.Text.Trim Then
                panelUser.Visible = False
                CatálogosToolStripMenuItem.Visible = False
                ModulosToolStripMenuItem.Visible = False
                UtileriasToolStripMenuItem.Visible = False
                mainOptions.Visible = True

                'Registra usuario en REGEDIT
                Dim key As Microsoft.Win32.RegistryKey
                key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(gsRegPath)
                key.SetValue("UsuarioActivo", UCase(Me.txtUser.Text.Trim))
                UsuarioActivo = CType(key.GetValue("UsuarioActivo"), String)

                'Inserta usuario
                Usuario.InsertaUsuarioConectado()
                Timer1.Enabled = True
                statusEmpresa.Text = "No conectado:"
                statusActividad.Text = " Esperando selección de empresa"
            Else
                MsgBox("La contraseña es incorrecta", MsgBoxStyle.Exclamation, "Aviso")
                txtPassWord.Clear()
                txtPassWord.Focus()
            End If
        Else
            MsgBox("El usuario no existe", MsgBoxStyle.Exclamation, "Aviso")
            txtUser.SelectAll()
            txtUser.Focus()
        End If
    End Sub

    Private Sub txtUser_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUser.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
            If txtUser.Text = "" Then
                MsgBox("Debes indicar el nombre del usuario", MsgBoxStyle.Exclamation, "Aviso")
                txtUser.Focus()
            Else
                txtPassWord.Focus()
            End If
        End If
    End Sub

    Private Sub txtUser_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtUser.TextChanged
        Dim texto As String = txtUser.Text
        If texto = "" Then
            Exit Sub
        End If
        Dim longtext As Integer = Len(texto)
        Dim caracter As String = Mid(texto, longtext, 1)
        Dim anterior As String = Mid(texto, 1, longtext - 1)
        If longtext = 1 Then
            txtUser.Text = UCase(caracter)
        Else
            txtUser.Text = anterior & UCase(caracter)
        End If
        txtUser.Select(longtext + 1, longtext + 1)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        milisegundo += 1
        If milisegundo = 9 Then
            milisegundo = 0
            segundo += 1

            If segundo = 1 Then
                frmEmpresas.ShowDialog()
                'CatálogosToolStripMenuItem.Visible = True
                'ModulosToolStripMenuItem.Visible = True
                'UtileriasToolStripMenuItem.Visible = True

                'Timer1.Enabled = False

                'segundo = 10
            End If
        End If
    End Sub

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        Close()

    End Sub

    Private Sub UsuariosActivosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsuariosActivosToolStripMenuItem.Click
        frmUsuariosConectados.ShowDialog()
    End Sub

    Private Sub RespaldarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RespaldarToolStripMenuItem.Click
        Dim TotalUsuarios As Integer = BuscarIntDatoInicial("Select Count(*) FROM UsuariosConectados")
        If TotalUsuarios > 1 Then
            MsgBox("El respaldo de la base de datos es un proceso exclusivo que requiere que no existan usuarios conectados ademas del usuario que hara el respaldo", MsgBoxStyle.Exclamation, "Aviso")
        Else
            frmRespaldar.ShowDialog()
        End If
    End Sub

    Private Sub RutasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RutasToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoRutas") = True Then
                frmCatalogoRutas.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoRutas.ShowDialog()
        End If

    End Sub

    Private Sub AutobusesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutobusesToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoAutobuses") = True Then
                frmCatalogoAutobuses.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoAutobuses.ShowDialog()
        End If


    End Sub

    Private Sub AlmacenesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoAlmacenes") = True Then
                frmCatalogoAlmacenes.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoAlmacenes.ShowDialog()
        End If

    End Sub

    Private Sub BombasDispensariosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoBombas") = True Then
                frmCatalogoBombas.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoBombas.ShowDialog()
        End If

    End Sub

    Private Sub MóduloDeLiquidacionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MóduloDeLiquidacionToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmLiquidacion") = True Then
                frmLiquidacion.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmLiquidacion.ShowDialog()
        End If


    End Sub

    Private Sub AignacionRutasConceptosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AignacionRutasConceptosToolStripMenuItem.Click

        If UsuarioActivo.Trim <> "ADMINISTRADOR" Then
            MsgBox("No tienes permiso para ingresar a esta opcion", MsgBoxStyle.Critical, "Aviso")
            Exit Sub
        End If

        frmConceptos.ShowDialog()

    End Sub

    Private Sub MóduloDeEmpleadosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MóduloDeEmpleadosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloEmpleados") = True Then
                frmModuloEmpleados.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmModuloEmpleados.ShowDialog()
        End If

    End Sub

    Private Sub MóduloDePagobusToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MóduloDePagobusToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmPagobus") = True Then
                frmPagobus.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmPagobus.ShowDialog()
        End If
    End Sub

    Private Sub PeriodosDeInfonavitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PeriodosDeInfonavitToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominas") = True Then
                frmPeriodoInf.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmPeriodoInf.ShowDialog()
        End If




    End Sub

    Private Sub PeriodosDeFonacotToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PeriodosDeFonacotToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominas") = True Then
                frmPeriodoFon.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmPeriodoFon.ShowDialog()
        End If

    End Sub

    Private Sub CatálogoDeAdeudosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CatálogoDeAdeudosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominas") = True Then
                frmAdeudos.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmAdeudos.ShowDialog()
        End If

    End Sub

    Private Sub SalariosMinimosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalariosMinimosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominas") = True Then
                frmSalariosMinimos.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmSalariosMinimos.ShowDialog()
        End If


    End Sub

    Private Sub PrecioDeVueltasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrecioDeVueltasToolStripMenuItem.Click

        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominas") = True Then
                frmPrecios.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmPrecios.ShowDialog()
        End If


    End Sub

    Private Sub NominasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NominasToolStripMenuItem.Click

        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominas") = True Then
                frmModuloNominas.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmModuloNominas.ShowDialog()
        End If

    End Sub

    Private Sub TanquesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TanquesToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoTanques") = True Then
                frmCatalogoTanques.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoTanques.ShowDialog()
        End If
    End Sub

    Private Sub FormulariosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FormulariosToolStripMenuItem.Click
        If UsuarioActivo.Trim <> "ADMINISTRADOR" Then
            MsgBox("No tienes permiso para ingresar a esta opcion", MsgBoxStyle.Critical, "Aviso")
            Exit Sub
        End If
        frmFormularios.ShowDialog()
    End Sub

    Private Sub UsuariosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsuariosToolStripMenuItem.Click
        If UsuarioActivo.Trim <> "ADMINISTRADOR" Then
            MsgBox("No tienes permiso para ingresar a esta opcion", MsgBoxStyle.Critical, "Aviso")
            Exit Sub
        End If
        frmUsuarios.ShowDialog()
    End Sub

    Private Sub EnviarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnviarToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmArchivos") = True Then
                frmEnvio.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmEnvio.ShowDialog()
        End If

    End Sub

    Private Sub ExtraerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExtraerToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmArchivos") = True Then
                frmExtraer.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmExtraer.ShowDialog()
        End If
    End Sub

    Private Sub BorrarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BorrarToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmArchivos") = True Then
                frmEliminar.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmEliminar.ShowDialog()
        End If
    End Sub
    Private Sub DieselToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DieselToolStripMenuItem.Click
        'If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
        'If TienePermiso("frmModuloDiesel") = True Then
        'frmConectaSerial.ShowDialog()
        'frmin()
        'Else
        'MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
        'End If
        'Else
        'frmConectaSerial.ShowDialog()
        'frmPruebaScanner.ShowDialog()
        'End If
        'frmModuloDiesel.ShowDialog()

        'frmIngresoDiesel.ShowDialog()
        'frmPruebasDiesel.ShowDialog()

        'If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
        'If TienePermiso("frmDiesel") = True Then
        ' frmDiesel.ShowDialog()
        ' Else
        ' MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
        ' End If
        ' Else
        ' frmDiesel.ShowDialog()
        'End If
    End Sub
    Private Sub ProductosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoProductos") = True Then
                frmCatalogoProductos.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoProductos.ShowDialog()
        End If
    End Sub
    Private Sub SubServiciosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubServiciosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmSubServicios") = True Then
                frmSubServicios.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmSubServicios.ShowDialog()
        End If
    End Sub
    Private Sub ServiciosToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ServiciosToolStripMenuItem1.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoServicios") = True Then
                frmCatalogoServicios.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoServicios.ShowDialog()
        End If
    End Sub
    Private Sub ActualizarOperadoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActualizarOperadoresToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmAltaHuellasOperadores") = True Then
                frmAltaHuellasOperadores.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmAltaHuellasOperadores.ShowDialog()
        End If
    End Sub
    Private Sub UniConceptoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UniConceptoToolStripMenuItem.Click
        frmCarga.ShowDialog()

    End Sub

    Private Sub MultiConceptoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MultiConceptoToolStripMenuItem.Click
        frmCargaMulti.ShowDialog()

    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

        milisegundo += 1
        If milisegundo = 9 Then
            'frmIngresoDiesel.Close()
            frmModuloDiesel.ShowDialog()
            milisegundo = 0
            Timer2.Enabled = False

        End If
    End Sub
    Private Sub AsignacionEmpleadosUsuariosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AsignacionEmpleadosUsuariosToolStripMenuItem.Click
        frmAsignacionBiometria.ShowDialog()
    End Sub

    Private Sub RendimientosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RendimientosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloDiesel") = True Then
                frmRendimientoStandard.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmRendimientoStandard.ShowDialog()
        End If
    End Sub

    Private Sub ImportarKilometrosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmKilometrosOperativos.ShowDialog()
    End Sub

    Private Sub RestaurarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RestaurarToolStripMenuItem.Click

    End Sub

    Private Sub CambiarDeUsuarioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CambiarDeUsuarioToolStripMenuItem.Click

    End Sub

    Private Sub MultipagosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MultipagosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModulodePagos") = True Then
                statusActividad.Text = "Cargando SDK de ContPAQ I Bancos..."
                Dim lSdkSubCtaDe As New SDKCONTPAQNGLib.TSdkCuenta
                Call iniciaObjetosSdk()
                statusActividad.Text = "Esperando ingreso a ContPAQ I Bancos..."
                lSdkSubCtaDe.setSesion(gSdkSesion)

                If gSdkSesion Is Nothing Then
                    MsgBox("No se conecto a ContPAQ I Bancos", MsgBoxStyle.Exclamation, "Aviso")
                    Exit Sub
                End If
                EsNuevo = True
                frmModulodePagos.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            statusActividad.Text = "Cargando SDK de ContPAQ I Bancos..."
            'Dim lSdkSubCtaDe As New SDKCONTPAQNGLib.TSdkCuenta
            'Call iniciaObjetosSdk()
            'statusActividad.Text = "Esperando ingreso a ContPAQ I Bancos..."
            'lSdkSubCtaDe.setSesion(gSdkSesion)

            'If gSdkSesion Is Nothing Then
            'MsgBox("No se conecto a ContPAQ I Bancos", MsgBoxStyle.Exclamation, "Aviso")
            'Exit Sub
            'End If
            EsNuevo = True
            frmModulodePagos.ShowDialog()
        End If
    End Sub

    Private Sub ProximosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProximosToolStripMenuItem.Click
        frmRMantenimientosP.ShowDialog()

    End Sub

    Private Sub RendimientosToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RendimientosToolStripMenuItem1.Click
        frmRDieselKms.ShowDialog()
    End Sub

    Private Sub ConsumosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConsumosToolStripMenuItem.Click
        frmRAbasDiesel.ShowDialog()

    End Sub

    Private Sub CuentasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Cuentas()
        MsgBox("Registros importados", MsgBoxStyle.Information, "Aviso")
    End Sub
    Sub Cuentas()
        ContabilidadConnection = "Server=" & Server.Trim & "\COMPAC;Database=ct2012Operadora; user id = SA; password = Compac123;"

        Dim Cuentas As New clsCuentasContables

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = ContabilidadConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn

        statusActividad.Text = "Buscando registros..."
        Application.DoEvents()

        Dim StrSql As String = "SELECT Id,Codigo,Nombre,Tipo,CtaMayor FROM Cuentas WHERE Afectable=1"

        cmdBuscar.CommandText = StrSql
        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim cIdValor02 As Integer = 0
        Dim Fecha As Date = Now()
        Dim Cont As Integer = 0
        Dim cIdDocum01 As Integer = 0
        Dim LargoCodigo As Integer = 0
        Dim PrimerDigito As String = ""
        Dim DosDigitos As String = ""
        Dim DigitoMayor = ""
        Dim CuentaTitulo As String = ""
        Dim CuentaSubtitulo As String = ""
        Dim CuentaMayor As String = ""


        Do While rdBuscar.Read()
            Cont = Cont + 1
            statusActividad.Text = "Insertando registros...." & Cont
            Application.DoEvents()

            Cuentas.Empresa = "Operadora Bellavista SA de CV"
            Cuentas.Abreviacion = "OBE"
            Cuentas.IdCuenta = rdBuscar("Id")
            Cuentas.Codigo = rdBuscar("Codigo").ToString.Trim
            Cuentas.Nombre = rdBuscar("Nombre").ToString.Trim
            Cuentas.Cuenta = Cuentas.Codigo & " " & Cuentas.Nombre
            Cuentas.Tipo = rdBuscar("Tipo").ToString.Trim
            Cuentas.CtaMayor = rdBuscar("CtaMayor")
            Cuentas.CInforme = 0
            Cuentas.CImpuestos = 0

            LargoCodigo = Len(Cuentas.Codigo) - 1
            PrimerDigito = Mid(Cuentas.Codigo, 1, 1)
            DosDigitos = Mid(Cuentas.Codigo, 1, 2)
            DigitoMayor = Mid(Cuentas.Codigo, 1, 4)

            For i = 1 To LargoCodigo
                CuentaTitulo = CuentaTitulo & "0"
            Next
            CuentaTitulo = PrimerDigito & CuentaTitulo
            For i = 2 To LargoCodigo
                CuentaSubtitulo = CuentaSubtitulo & "0"
            Next
            CuentaSubtitulo = DosDigitos & CuentaSubtitulo

            For i = 4 To LargoCodigo
                CuentaMayor = CuentaMayor & "0"
            Next
            CuentaMayor = DigitoMayor & CuentaMayor

            Cuentas.Titulo = CuentaTitulo & " " & BuscarStrDatoContabilidad("SELECT Nombre FROM Cuentas WHERE Codigo='" & CuentaTitulo & "'")
            Cuentas.Subtitulo = CuentaSubtitulo & " " & BuscarStrDatoContabilidad("SELECT Nombre FROM Cuentas WHERE Codigo='" & CuentaSubtitulo & "'")
            Cuentas.Mayor = CuentaMayor & " " & BuscarStrDatoContabilidad("SELECT Nombre FROM Cuentas WHERE Codigo='" & CuentaMayor & "'")
            Cuentas.Insertar()
            CuentaTitulo = ""
            CuentaSubtitulo = ""
            CuentaMayor = ""
        Loop

        statusActividad.Text = "Listo"
        Application.DoEvents()
    End Sub


    Private Sub ContabilidadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmCuboContables.ShowDialog()

    End Sub

    Private Sub UPDATEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim cnConn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader

        Try
            cnConn.ConnectionString = CitraConnection
            strSql = "SELECT C.IdAutobus,A.cCodigoC01,IdEgreso FROM CuboEgresos C INNER JOIN Autobuses A ON C.IdAutobus=A.IdAutobus WHERE IdEgreso>46937"

            cmdBuscar.Connection = cnConn
            cmdBuscar.CommandText = strSql

            cnConn.Open()
            rdBuscar = cmdBuscar.ExecuteReader

            Do While rdBuscar.Read()
                Call SetSqlCitra("UPDATE CuboEgresos SET NoInt='" & rdBuscar("cCodigoC01").ToString.Trim & "' WHERE IdEgreso=" & rdBuscar("IdEgreso"))
            Loop
        Catch ex As Exception
            MessageBox.Show(ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try

        MsgBox("Listo")
    End Sub

    Private Sub ClasificarCuentasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClasificarCuentasToolStripMenuItem.Click
        frmCuentasContpaq.ShowDialog()

    End Sub

    Private Sub PRUEBAToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
      
    End Sub
    Sub ATUALIZARNOECOS()
        Dim cnconn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader

        cnconn.ConnectionString = CitraConnection
        strSql = "Select Fecha,IdLiquidacion,cCodigoC01 FROM Liquidacion L INNER JOIN Autobuses A ON L.IdAutobus=A.idAutobus WHERE CONVERT(VARCHAR,Fecha,101)>='02/01/2013'"

        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql

        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Fecha As Date
        Dim NoEco As String
        Dim Cont As Integer = 0

        Do While rdBuscar.Read()
            Fecha = rdBuscar("Fecha")
            NoEco = rdBuscar("cCodigoC01").ToString.Trim
            Call SetSqlCitra("UPDATE Liquidacion SET Importe01=" & Fecha.Year & ", Importe02=" & Fecha.Month & ",Texto01='" & NoEco & "' WHERE IdLiquidacion=" & rdBuscar("IdLiquidacion"))
            Cont = Cont + 1
            statusActividad.Text = Cont & " Registros procesados"
            Application.DoEvents()
        Loop

        MsgBox("Listo", MsgBoxStyle.Information, "Aviso")
    End Sub

    Private Sub InformeEconomicoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InformeEconomicoToolStripMenuItem.Click
        frmInformeEconomico.ShowDialog()
    End Sub

    Private Sub ActualizaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'frmActualizaCuentas.ShowDialog()
        Dim cnconn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader

        cnconn.ConnectionString = NominasConnection
        strSql = "Select * FROM NOM10001"

        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql

        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Do While rdBuscar.Read()
            Call SetSqlCitra("UPDATE Empleados SET CuentaPago='" & rdBuscar("CuentaPagoElectronico") & "', CuentaCW='" & rdBuscar("CuentaCW") & "' WHERE Codigo='" & rdBuscar("CodigoEmpleado") & "'")

        Loop
        MsgBox("Listo", MsgBoxStyle.Information, "Aviso")

    End Sub

    Private Sub EvaluaciónOperadoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EvaluaciónOperadoresToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloEvaluacion") = True Then
                frmE_Evaluacion.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmE_Evaluacion.ShowDialog()
        End If
    End Sub

    Private Sub LlantasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LlantasToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloLlantas") = True Then
               Dim Plataforma As String = System.Environment.OSVersion.Platform.ToString()
                Dim Archivos As String = ""
                If Plataforma = "Win32NT" Then
                    Archivos = "C:\Program Files"
                Else
                    Archivos = "C:\Program Files (x86)"
                End If

                Dim startinfo As System.Diagnostics.ProcessStartInfo
                Dim pStart As New System.Diagnostics.Process
                startinfo = New System.Diagnostics.ProcessStartInfo("C:\SLl\Llantas.exe")

                Bitacora.RegistraActividad("Ingresó al módulo de llantas")
                Usuario.Ubicacion("Módulo de Llantas")
                pStart.StartInfo = startinfo
                pStart.Start()
                Bitacora.RegistraActividad("Cerró el módulo de llantas")
                Usuario.Ubicacion("Ventana Principal")
                pStart.WaitForExit()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            Dim Plataforma As String = System.Environment.OSVersion.Platform.ToString()
            Dim Archivos As String = ""
            If Plataforma = "Win32NT" Then
                Archivos = "C:\Program Files"
            Else
                Archivos = "C:\Program Files (x86)"
            End If

            Dim startinfo As System.Diagnostics.ProcessStartInfo
            Dim pStart As New System.Diagnostics.Process
            startinfo = New System.Diagnostics.ProcessStartInfo("C:\SLl\Llantas.exe")

            Bitacora.RegistraActividad("Ingresó al módulo de llantas")
            Usuario.Ubicacion("Módulo de Llantas")
            pStart.StartInfo = startinfo
            pStart.Start()
            Bitacora.RegistraActividad("Cerró el módulo de llantas")
            Usuario.Ubicacion("Ventana Principal")
            pStart.WaitForExit()

            
        End If
    End Sub

    Private Sub PRUEBAToolStripMenuItem_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'Carga Libreria
        Dim RutaDLL As String = ""
        Dim cCodigoBol As String = ""
        Dim cCodigoASE As String = ""

        Try

            Dim key As Microsoft.Win32.RegistryKey
            key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(gsRegPath)
            RutaDLL = CType(key.GetValue("RutaDLL"), String)
            cCodigoBol = CType(key.GetValue("cCodigoBol"), String)
            cCodigoASE = CType(key.GetValue("cCodigoASE"), String)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
            MsgBox("Se interrumpio el proceso", MsgBoxStyle.Exclamation, "Aviso")
        End Try

        'Carga SDK
        Dim lError As Integer

        Try
            System.IO.Directory.SetCurrentDirectory(RutaDLL)
            lError = SDK_AdminPAQ.fInicializaSDK
            If lError <> 0 Then
                MensajeError(lError)
                End
            End If
        Catch ex As Exception
            MsgBox("No se pudo cargar el SDK de AdminPAQ", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End Try

        'Abre Empresa de AdminPAQ
        Try
            lError = SDK_AdminPAQ.fAbreEmpresa(Comercial)
            If lError <> 0 Then
                MensajeError(lError)
            End If
        Catch ex As Exception
            MsgBox("No se pudo abrir la empresa de AdminPAQ", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End Try

        Dim lFecha As String
        Dim lRet As Long
        lFecha = Format(Now.Month, "00") & "/"
        lFecha = lFecha & Format(Now.Day, "00") & "/"
        lFecha = lFecha & Format(Now.Year, "0000")

        lRet = SDK_AdminPAQ.fSaldarDocumento_Param("21", "", "1105", "26", "", "20", 1.16, 1, lFecha)
        If lRet <> 0 Then
            MensajeError(lRet)
        Else
            MsgBox("Listo")
        End If
    End Sub

    Private Sub MáximosYMínimosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MáximosYMínimosToolStripMenuItem.Click
        frmMaximosMinimos.ShowDialog()

    End Sub

    Private Sub PruebaToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ImportaTablas(1)

    End Sub

    Private Sub PresupuestoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PresupuestoToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmPresupuesto") = True Then
                frmPresupuesto.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmPresupuesto.ShowDialog()
        End If
    End Sub

    Private Sub AltaHuellasUsuariosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltaHuellasUsuariosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) = "ADMINISTRADOR" Then
            frmAltaHuellasUsuarios.ShowDialog()
        Else
            MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
        End If
    End Sub

    Private Sub AltaHuellasPersonalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltaHuellasPersonalToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmAltaHuellasPersonal") = True Then
                frmAltaHuellasPersonal.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmAltaHuellasPersonal.ShowDialog()
        End If
    End Sub

    Private Sub TEMPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim cnconn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader

        cnconn.ConnectionString = CitraConnection
        strSql = "Select * FROM Empleados WHERE IDEMPLEADO>0 AND IDEMPLEADO<=990"

        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql

        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Nombre As String
        Dim Paterno As String
        Dim Materno As String
        Dim Completo As String

        Do While rdBuscar.Read()
            Nombre = rdBuscar("ApellidoMaterno")
            Paterno = rdBuscar("Nombre")
            Materno = rdBuscar("ApellidoPaterno")
            Completo = Paterno & " " & Materno & " " & Nombre
            Call SetSqlCitra("UPDATE Empleados SET Nombre='" & Nombre & "', ApellidoPaterno='" & Paterno & "', ApellidoMaterno='" & Materno & "', NombreCompleto='" & Completo & "' WHERE IdEmpleado=" & rdBuscar("IdEmpleado"))
        Loop
        MsgBox("Listo", MsgBoxStyle.Information, "Aviso")
    End Sub

    Private Sub PruebasDieselToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PruebasDieselToolStripMenuItem.Click
        frmPruebasDiesel.ShowDialog()

    End Sub

    Private Sub TarjetasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TarjetasToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmTarjetas") = True Then
                frmTarjetas.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmTarjetas.ShowDialog()
        End If
    End Sub

    Private Sub ValidarLayourToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ValidarLayourToolStripMenuItem.Click
        frmValidaLayout.ShowDialog()
        'CargaLCBInvierte()
    End Sub
    Sub CargaLCBInvierte()
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand

        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT * From Empleados "

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Codigo As String = ""
        Do While rdBuscar.Read()

            Codigo = rdBuscar("Codigo").ToString.Trim
            Call SetSqlNominas("UPDATE NOM10001 SET IdPuesto=" & rdBuscar("IdPuesto") & " WHERE CodigoEmpleado='" & Codigo & "'")
        Loop
    End Sub

    Private Sub PruebaToolStripMenuItem_Click_3(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim cnconn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader

        cnconn.ConnectionString = CitraConnection
        strSql = "Select * FROM Tarjetas"

        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql

        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader


        Dim Codigo As String

        Do While rdBuscar.Read()
            Codigo = rdBuscar("CodigoTarjeta")

            Call SetSqlCitra("UPDATE Tarjetas SET CodigoTarjeta='00" & Codigo & "' WHERE IdTarjeta=" & rdBuscar("IdTarjeta"))
        Loop
        MsgBox("Listo", MsgBoxStyle.Information, "Aviso")
    End Sub

    Private Sub RolesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RolesToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCatalogoRoles") = True Then
                frmCatalogoRoles.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCatalogoRoles.ShowDialog()
        End If
    End Sub

    Private Sub OptoControlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptoControlToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloOptocontrol") = True Then
                frmModuloOptocontrol.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmOptocontrol.ShowDialog()
        End If
    End Sub

    Private Sub PlanesDeOperaciónToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlanesDeOperaciónToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmPlanOperacion") = True Then
                frmPlanOperacion.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmPlanOperacion.ShowDialog()
        End If
    End Sub


    Private Sub NominasToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        
    End Sub

    Private Sub DiasDeOperacionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiasDeOperacionToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmDiasOperacion") = True Then
                frmDiasOperacion.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmDiasOperacion.ShowDialog()
        End If
    End Sub

    Private Sub NominasToolStripMenuItem1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bellavistaNominas.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloNominasBellavista") = True Then
                frmModuloNominasBellavista.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmModuloNominasBellavista.ShowDialog()
        End If
    End Sub

    Private Sub EmpresasPorUsuarioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EmpresasPorUsuarioToolStripMenuItem.Click
        If UsuarioActivo.Trim <> "ADMINISTRADOR" Then
            MsgBox("No tienes permiso para ingresar a esta opcion", MsgBoxStyle.Critical, "Aviso")
            Exit Sub
        End If
        frmEmpresasUsuarios.ShowDialog()
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        frmEmpresas.ShowDialog()
    End Sub

    Private Sub CotizacionesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ModuloDeCotizacionesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloCotizaciones") = True Then
                frmModuloCotizaciones.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmModuloCotizaciones.ShowDialog()
        End If
    End Sub

    Private Sub SolicitudDeRefaccionesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmCot_Solicitud") = True Then
                frmCot_Solicitud.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmCot_Solicitud.ShowDialog()
        End If
    End Sub

    Private Sub EJECUTAToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim cnconn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader

        cnconn.ConnectionString = CitraConnection
        strSql = "SELECT IDTARJETA,CODIGOTARJETA,NOMBRE,EMPRESA FROM TARJETAS T INNER JOIN OPERADORESGLOBAL O ON T.IDOPERADOR=O.IDOPERADOR WHERE EMPRESA IN ('ACG','ASP') ORDER BY EMPRESA"

        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql

        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Codigo As Integer

        Do While rdBuscar.Read()
            Codigo = rdBuscar("CodigoTarjeta")

            Call SetSqlCitra("UPDATE Tarjetas SET CodigoTarjeta='" & Codigo & "' WHERE IdTarjeta=" & rdBuscar("IdTarjeta"))
        Loop
        MsgBox("Listo", MsgBoxStyle.Information, "Aviso")
    End Sub

    Private Sub DIASToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DIASToolStripMenuItem.Click
        Dim cnconn As New SqlConnection
        Dim strSql As String
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader
        '
        cnconn.ConnectionString = CitraConnection
        strSql = "SELECT * FROM Liquidacion WHERE TotalBoletos>0"

        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql
        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Fecha As Date
        Dim Cont As Integer = 0

        Do While rdBuscar.Read()
            Fecha = rdBuscar("Fecha")
            Call SetSqlCitra("UPDATE Liquidacion SET Importe04=" & Fecha.Month & ",Importe05=" & Fecha.Year & ",Texto04='" & Fecha.ToShortDateString & "' WHERE IdLiquidacion=" & rdBuscar("IdLiquidacion"))
            Cont = Cont + 1
            statusActividad.Text = "Actualizando " & Cont & " registros"
            Application.DoEvents()

        Loop
        MsgBox("Listo", MsgBoxStyle.Information, "Aviso")



    End Sub
    Private Sub Excel()

        Dim xl As Object
        Dim wb As Object

        'Crear objeto excel
        xl = CreateObject("Excel.Application")
        xl.Visible = False
        wb = xl.activeworkbook
        wb = xl.Workbooks.Open _
        ("C:\Tarjetas.XLS", True, True, , "")

        Dim rng As Integer = 1
        Dim col As Integer = 1
        Dim i As Integer = 1

        Dim Reales As Double = 0

        Dim Tarjeta As New clsTarjetas

        For i = 2 To 289
            Tarjeta.IdTarjeta = wb.sheets(1).cells(i, 1).value
            Tarjeta.CodigoTarjeta = wb.sheets(1).cells(i, 8).value
            Tarjeta.Actualizar()
        Next

        'cerramos el archivo Excel
        wb.Close(SaveChanges:=False)
        xl.Quit()
        MsgBox("Listo")

    End Sub
  
    Private Sub ReporteDeKilometrosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReporteDeKilometrosToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmRKilometros") = True Then
                frmRKilometros.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmRKilometros.ShowDialog()
        End If
    End Sub

    Private Sub DefinirLiquidadoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DefinirLiquidadoresToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmLiquidadores") = True Then
                frmLiquidadores.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmLiquidadores.ShowDialog()
        End If
    End Sub

    Private Sub AlmacenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlmacenToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmModuloAlmacen") = True Then
                frmModuloAlmacen.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmModuloAlmacen.ShowDialog()
        End If
    End Sub

    Private Sub ÓrdenDeDieselToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ÓrdenDeDieselToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmOrdenDiesel") = True Then
                frmOrdenDiesel.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmOrdenDiesel.ShowDialog()
        End If


    End Sub

    Private Sub DieselToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DieselToolStripMenuItem2.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmDiesel") = True Then
                frmDiesel.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmDiesel.ShowDialog()
        End If
    End Sub

    Private Sub HuellasDactilaresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HuellasDactilaresToolStripMenuItem.Click
        If UCase(UsuarioActivo.Trim) <> "ADMINISTRADOR" Then
            If TienePermiso("frmAltaHuellasOperadores") = True Then
                frmAltaHuellasOperadores.ShowDialog()
            Else
                MsgBox("No tiene permiso para ingresar a esta opcion", MsgBoxStyle.Exclamation, "Aviso")
            End If
        Else
            frmAltaHuellasOperadores.ShowDialog()
        End If
    End Sub

    Private Sub DesbloquearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DesbloquearToolStripMenuItem.Click
        Dim i As Short
        i = Desbloquear(1)
    End Sub

    Private Sub MóduloDeNominasToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MóduloDeNominasToolStripMenuItem.Click

    End Sub

    Private Sub TemporalToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TemporalToolStripMenuItem.Click
        frmImportacionMasiva.ShowDialog()

    End Sub
End Class